<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.sPRingframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd // 和上面的都是對(duì)應(yīng)存在的 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- 配置數(shù)據(jù)源 -->
<!-- 定義使用C3P0連接池的數(shù)據(jù)源 -->
<bean id="dbDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"><!-- 指定連接數(shù)據(jù)庫(kù)的JDBC驅(qū)動(dòng) --> <property name="driverClass"> <value>${jdbc.driverClassName}</value> </property><!-- 連接數(shù)據(jù)庫(kù)所用的URL --> <property name="jdbcUrl"> <value>${jdbc.db.url}</value> </property><!-- 連接數(shù)據(jù)庫(kù)的用戶名 --> <property name="user"> <value>${jdbc.db.username}</value> </property><!-- 連接數(shù)據(jù)庫(kù)的密碼 --> <property name="passWord"> <value>${jdbc.db.password}</value> </property><!-- 設(shè)置數(shù)據(jù)庫(kù)連接池的最大連接數(shù) --> <property name="maxPoolSize"> <value>${jdbc.maxPoolSize}</value> </property><!-- 設(shè)置數(shù)據(jù)庫(kù)連接池的最小連接數(shù) --> <property name="minPoolSize"> <value>${jdbc.minPoolSize}</value> </property><!-- 設(shè)置數(shù)據(jù)庫(kù)連接池的初始化連接數(shù) --> <property name="idleConnectionTestPeriod"> <value>${jdbc.idleConnectionTestPeriod}</value> </property><!-- 設(shè)置數(shù)據(jù)庫(kù)連接池的連接的最大空閑時(shí)間,單位為秒 --> <property name="maxIdleTime"> <value>${jdbc.maxIdleTime}</value> </property> <property name="testConnectionOnCheckout"> <value>${jdbc.testConnectionOnCheckout}</value> </property></bean><!-- 配置一個(gè)事務(wù)通知 --><tx:advice id="txAdvice" transaction-manager="dbTransactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="save*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="insert*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="create*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="delete*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="remove*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="*" read-only="true"/> </tx:attributes></tx:advice><!-- 使用XML來(lái)使用事務(wù)管理--> <aop:config><!-- 配置一個(gè)切面,和需要攔截的類和方法 --> <aop:pointcut id="txPointcut" expression="execution(* com..service.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/></aop:config></beans>
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注