Spring 整合 Hibernate 的一处简化配置[转]
在过去使用 Spring 整合 Hibernate 的时候,都是用这样的配置方式。
每当需要加入一个新的 VO 时,我需要过来修改配置文件,来引入对新的 VO 的支持。
现在我使用的时候,是这么配的:
做项目开发的时候,就再也没有改过配置。
还可以使用上面这种配置
注明一下,我所用的 Spring 版本是 2.0 的。
摘自:http://www.blogjava.net/steady/archive/2007/08/17/137527.html
1<bean id ="sessionFactory" lazy-init ="true"
2 class ="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
3 <property name ="mappingResources">
4 <list>
5 <value>resources/icustomer/Contact.hbm.xml</value>
6 <value>resources/icustomer/Customer.hbm.xml</value>
7 </list>
8 </property>
9 ...................
10</bean>每当需要加入一个新的 VO 时,我需要过来修改配置文件,来引入对新的 VO 的支持。
现在我使用的时候,是这么配的:
1<bean id ="sessionFactory" lazy-init ="true"
2 class ="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
3 <property name ="mappingLocations" >
4 <list>
5 <value > classpath:resources/**/*.hbm.xml </value>
6 </list>
7 </property>
8 .....................
9</bean>做项目开发的时候,就再也没有改过配置。
1<property name="mappingDirectoryLocations">
2 <list>
3 <value>classpath*:domain/mappings/</value>
4 </list>
5</property>还可以使用上面这种配置
注明一下,我所用的 Spring 版本是 2.0 的。
摘自:http://www.blogjava.net/steady/archive/2007/08/17/137527.html