zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    【u244】山地考察
    【u246】卫星照片
    【z08】乌龟棋
    【22.95%】【hdu 5992】Finding Hotels
    【t048】水流
    【b601】能量项链
    【b702】字符串的展开
    【a903】石子归并
    【9915】乘积最大
    JavaEE(24)
  • 原文地址:https://www.cnblogs.com/light-zhang/p/9921442.html
Copyright © 2011-2022 走看看