Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate - spring annotated entities not scanned from within jar

I have a package containing annotated entity classes that I import into my web project. When tomcat deploys the project the entity class that are in the jar are not scanned for annotations. is there a way to tell spring to search for annotated classes inside a jar file? i.e. :

<context:component-scan base-package="{path to jar or something}"/>
like image 932
Noam Nevo Avatar asked Oct 20 '10 17:10

Noam Nevo


1 Answers

Look for: http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.html

the second example:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
  <property name="dataSource" ref="dataSource"/>
  <property name="packagesToScan" value="test.package"/>
</bean>

Put two wildcards behind to scan all subpackages. (ex: "test.package.**")

like image 199
SvBu Avatar answered Nov 15 '22 06:11

SvBu