<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="jdbcUrl">
<value>jdbc:mysql://localhost:3306/new_log?characterEncoding=gbk</value>
</property>
<property name="properties">
<props>
<prop key="c3p0.minPoolSize">1</prop>
<prop key="hc3p0.maxPoolSize">10</prop>
<prop key="hc3p0.timeout">60</prop>
<prop key="c3p0.max_statement">50</prop>
<prop key="c3p0.testConnectionOnCheckout">true</prop>
<prop key="hibernate.c3p0.testConnectionOnCheckout">false</prop>
<prop key="user">root</prop>
<prop key="password"></prop>
</props>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" singleton="true">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<list>
<value>jfw/pojo/Login.hbm.xml</value>
<value>jfw/pojo/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- 事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="baseProxy" lazy-init="true" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean><!-- =========================================================================== -->
<!-- 需要事务处理的配置 -->
<bean id="LoginDao" parent="baseProxy">
<property name="target">
<bean class="jfw.dao.LoginDao" autowire="byName"/>
</property>
</bean>
<!-- 不需要事务处理的配置 -->
<!--
<bean id="BaseDao" class="jfw.dao.BaseDao">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
-->
</beans>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="jdbcUrl">
<value>jdbc:mysql://localhost:3306/new_log?characterEncoding=gbk</value>
</property>
<property name="properties">
<props>
<prop key="c3p0.minPoolSize">1</prop>
<prop key="hc3p0.maxPoolSize">10</prop>
<prop key="hc3p0.timeout">60</prop>
<prop key="c3p0.max_statement">50</prop>
<prop key="c3p0.testConnectionOnCheckout">true</prop>
<prop key="hibernate.c3p0.testConnectionOnCheckout">false</prop>
<prop key="user">root</prop>
<prop key="password"></prop>
</props>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" singleton="true">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<list>
<value>jfw/pojo/Login.hbm.xml</value>
<value>jfw/pojo/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- 事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="baseProxy" lazy-init="true" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean><!-- =========================================================================== -->
<!-- 需要事务处理的配置 -->
<bean id="LoginDao" parent="baseProxy">
<property name="target">
<bean class="jfw.dao.LoginDao" autowire="byName"/>
</property>
</bean>
<!-- 不需要事务处理的配置 -->
<!--
<bean id="BaseDao" class="jfw.dao.BaseDao">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
-->
</beans>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货