问题描述:
在spring配置文件中如果有多个*.hbm.xml文件的话,无论是项目开发过程中还是维护过程中修改起来都会很麻烦切容易出错
这时我们可以把name="mappingResources"改为name="mappingDirectoryLocations",然后只需要配置*.hbm.xml文件所在目录就行了
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<!--<property name="mappingResources">
<list>
<value>classpath:/com/crm/entity</value>
<value>com/crm/entity/BasDict.hbm.xml</value>
<value>com/crm/entity/CstActivity.hbm.xml</value>
<value>com/crm/entity/CstCustomer.hbm.xml</value>
<value>com/crm/entity/CstLinkman.hbm.xml</value>
<value>com/crm/entity/CstService.hbm.xml</value>
<value>com/crm/entity/SalChance.hbm.xml</value>
<value>com/crm/entity/SalPlan.hbm.xml</value>
<value>com/crm/entity/SysRight.hbm.xml</value>
<value>com/crm/entity/SysRole.hbm.xml</value>
<value>com/crm/entity/SysRoleRight.hbm.xml</value>
<value>com/crm/entity/SysUser.hbm.xml</value>
<value>com/crm/entity/VOrders.hbm.xml</value>
<value>com/crm/entity/VOrdersLine.hbm.xml</value>
<value>com/crm/entity/VProduct.hbm.xml</value>
<value>com/crm/entity/VStorage.hbm.xml</value>
</list>
</property>-->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/crm/entity</value>
</list>
</property>
<property name="hibernateProperties">
<value>
<!-- hibernate.dialect=org.hibernate.dialect.MySQLDialect -->
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.hbm2dll.auto=update
hibernate.show_sql=true
hibernate.format_sql=true
</value>
</property>
</bean>