读书人

spring、hibernate调整配置

发布时间: 2013-07-24 14:36:29 作者: rapoo

spring、hibernate整合配置
spring与hibernate整合配置非常灵活:
1、在applicationContext.xml中引入hibernate.cfg.xml,如下:

<bean id="sessionFactory" ref="dataSource"/><!-- 使用hibernate自身的配置文件配置 <property name="configLocations"><list><value>classpath:cn/itcast/spring/hibernate/hibernate.cfg.xml</value></list></property></bean>



2、将hibernate相关配置配在applicationContext.xml中
<!-- 本地会话工厂bean,spring整合hibernate的核心接口 --><bean id="sessionFactory" ref="dataSource"/><!-- 指定hibernate自身的属性 --><property name="hibernateProperties"><props><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop><prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop></props></property><!-- 从指定目录下查找映射文件--><property name="mappingDirectoryLocations"><list><value>cn/itcast/spring/domain</value></list></property> <!-- 映射文件的位置<property name="mappingResources"><list><value>cn/itcast/spring/domain/Customer.hbm.xml</value></list></property> --></bean>

读书人网 >行业软件

热点推荐