Http://www.blogjava.net/sean/archive/2009/01/29/252685.html
[Tips] Packagestoscan of new features of Spring 2.5.6Posted on 2009-01-29 02:59 Laogao Reading (3790) Comments (0) Edit Favorites categories: on Java
If you use the earlier version of spring, you configure Hibernate object relational mappings just by using annotation annotations rather than traditional XML methods. So when configuring Sessionfactory through Org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean, you must be annotatedclasses , Annotatedpackages has an inability to say the feeling of chest tightness, so high configuration of spring, how in this a small link can not do more flexible, must be a handwritten class path.
It is estimated that a lot of people have chosen to inherit a custom subclass from Annotationsessionfactorybean, implement the scan logic themselves, and find the @entity annotated class list configuration.
One of the less noticeable improvements in Spring 2.5.6 is the addition of a new approach to Annotationsessionfactorybean:
Setpackagestoscan (string[] packagestoscan)
With this approach, we no longer need to implement the entity class scan by ourselves, directly in the spring configuration file Annotationsessionfactorybean This section to add a property similar to the following ( Suppose you need to load the entity class that contains the package name match this string "Com.**.bo"):
< property name = "Packagestoscan" value = "Com.**.bo"/>
You can also specify more than 1 matching strings in the form of a list, such as:
< property name = "Packagestoscan" >
< list >
< value > Com.abc.core.bo </value >
< value > Com.abc.auditing.bo </value >
</list >
</Property >
Example:
<property name= "Packagestoscan" >
<list>
<value>com.def.modules.*.bean</value>
<value>com.abc.**.bean</value>
</list>
</property>