spring 事务AOP配置管理

  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
    <!-- 声明使用注解式事务 -->
    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
    
    <!-- 配置事务通知 -->
    <tx:advice id="txAdvice"     transaction-manager="transactionManager">
        <tx:attributes>
            <!-- get find 读操作 -->
            <tx:method name="get*" isolation="DEFAULT" propagation="SUPPORTS" rollback-for="Exception" read-only="true" />
            <tx:method name="find*" isolation="DEFAULT" propagation="SUPPORTS" rollback-for="Exception" read-only="true" />
            <tx:method name="count*" isolation="DEFAULT" propagation="SUPPORTS" rollback-for="Exception" read-only="true" />
            <!-- create delete update 写操作 -->
            <tx:method name="create*" isolation="REPEATABLE_READ" propagation="REQUIRED" rollback-for="Exception" read-only="false" />
            <tx:method name="delete*" isolation="REPEATABLE_READ" propagation="REQUIRED" rollback-for="Exception" read-only="false" />
            <tx:method name="update*" isolation="REPEATABLE_READ" propagation="REQUIRED" rollback-for="Exception" read-only="false" />
        </tx:attributes>
    </tx:advice>
    <!-- 配置织入 -->
    <aop:config>
        <!-- 配置切点表达式 -->
        <aop:pointcut id="txAdvicePointcut" expression="execution(* com.cats.services.*.impl..*(..))" />
        <!-- 配置切面 : 通知+切点 advice-ref:通知的名称 pointcut-ref:切点的名称 -->
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txAdvicePointcut" />
    </aop:config>
原文地址:https://www.cnblogs.com/light-zhang/p/9921442.html