首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

spring、hibernate调整配置

2013-07-24 
spring、hibernate整合配置spring与hibernate整合配置非常灵活:1、在applicationContext.xml中引入hibernate

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>

热点排行