<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" ":/spring-beans.dtd">
<beans>
<!-- 定义受环境影响易变的变量 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
<!-- <value>classpath:proxool.properties</value>-->
</property>
</bean>
<!-- 数据源配置,在测试环境使用 -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- Connection Info, 使用P6spy记录sql -->
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- 数据源配置,在生产环境使用应用服务器的数据库连接池 -->
<!--
<jee:jndi-lookup id="dataSource"
jndi-name="java:comp/env/jdbc/ShowcaseDB" />
-->
<!-- Hibernate配置 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
<prop key="hibernate.current_session_context_class">${hibernate.current_session_context_class}</prop>
</props>
</property>
<!--
<property name="annotatedClasses"> <list>
<value>test.at21.orm.model.Tbl</value> </list> </property>
-->
<property name="packagesToScan" value="test.**.model">
</property>
</bean>
<!-- 事务管理器配置,单数据源事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 事务管理器配置,多数据源JTA事务-->
<!--
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager or
WebLogicJtaTransactionManager" />
-->
<bean id="hibernateDao" class="com.at21.orm.hibernate.HibernateDao"
singleton="false">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="tblManager" class="test.at21.orm.service.TblManager">
<property name="dao" ref="hibernateDao" />
</bean>
</beans>
spring hibernate 配置文件
最新推荐文章于 2023-03-29 22:26:39 发布