Spring 中数据源和数据库连接池配置的几种
展开全部
一、 数据源的配置:
* 与 Hibernate 集成最常见的一种:
<!-- 配置 sessionFactory -->
< bean id = "sessionFactory" class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
< property name = "configLocation" >
< value > classpath:hibernate.cfg .xml </ value >
</ property >
<!-- < property name = "configLocation" value = "classpath:hibernate.cfg.xml" >
</ property > -->
</ bean >
<!-- 配置事务管理器 -->
< bean id = "transactionManager" class = "org.springframework.orm.hibernate3.HibernateTransactionManager" >
< property name = "sessionFactory" >
< ref local = "sessionFactory" />
</ property >
</ bean >
* 与 Hibernate 集成最常见的一种:
<!-- 配置 sessionFactory -->
< bean id = "sessionFactory" class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
< property name = "configLocation" >
< value > classpath:hibernate.cfg .xml </ value >
</ property >
<!-- < property name = "configLocation" value = "classpath:hibernate.cfg.xml" >
</ property > -->
</ bean >
<!-- 配置事务管理器 -->
< bean id = "transactionManager" class = "org.springframework.orm.hibernate3.HibernateTransactionManager" >
< property name = "sessionFactory" >
< ref local = "sessionFactory" />
</ property >
</ bean >
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询