Spring 整合 Hibernate 的一處簡化配置
原文:http://www.tkk7.com/steady/archive/2007/08/17/137527.html

在過去使用 Spring 整合 Hibernate 的時候,都是用這樣的配置方式。

<bean id="sessionFactory" lazy-init="true"
      class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    
<property name="mappingResources">
        
<list>
            
<value>resources/icustomer/Contact.hbm.xml</value>
            
<value>resources/icustomer/Customer.hbm.xml</value>
        
</list>
    
</property>
    .
</bean>

每當需要加入一個新的 VO 時,我需要過來修改配置文件,來引入對新的 VO 的支持。

現在我使用的時候,是這么配的:
<bean id="sessionFactory" lazy-init="true"
      class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    
<property name="mappingLocations">
        
<list>
            
<value>classpath:resources/**/*.hbm.xml</value>
        
</list>
    
</property>
    .
</bean>

做項目開發的時候,就再也沒有改過配置。