<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd" default-lazy-init="false" default-autowire="byType"> <!-- 事务管理对象 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- 拦截模式 --> <aop:config proxy-target-class="false"> <aop:advisor pointcut="execution(* com.mortals..*Service.*(..))" advice-ref="txAdvice" /> </aop:config> <!-- 事务传播方式 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <!--tx:method name="get*" read-only="true"/ --> <!--<tx:method name="*" read-only="false" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException,Exception" />--> <tx:method name="remove*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="delete*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="change*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="create*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="update*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="modify*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="execute*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="excute*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="start*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="increment*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="do*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="audit*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="notify*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="send*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="save*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="doForce*" propagation="REQUIRES_NEW" rollback-for="com.mortals.framework.exception.AppException" /> <!--<tx:method name="*" read-only="true" />--> </tx:attributes> </tx:advice> </beans>