Spring配置文件中引入sessionFactory
作者:
pure_joy | 来源:发表于
2018-06-11 11:14 被阅读22次//第一种方式
<bean id="sessionFactory1" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
//第二种方式
<bean id="sessionFactory2"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!--映射文件所在路径 -->
<property name="mappingDirectoryLocations">
<list>
<!--spring容器会去该包及子包下搜索所有映射文件-->
<value>com/djx/spring/spring/hibernate</value>
</list>
</poperty>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBialect</prop><!--数据库方言-->
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop><!--创建表-->
</props>
</property>
</bean>
本文标题:Spring配置文件中引入sessionFactory
本文链接:https://www.haomeiwen.com/subject/dlwceftx.html
网友评论