zoukankan      html  css  js  c++  java
  • Spring的transaction事务

     1    <!--声明事务-->
     2     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
     3         <property name="dataSource" ref="dataSource"/>
     4     </bean>
     5 
     6     <!--结合AOP实现事务的织入-->
     7     <!--配置事务通知-->
     8     <tx:advice id="txAdvice" transaction-manager="transactionManager">
     9         <!--给哪些方法配置事务-->
    10         <tx:attributes>
    11             <!--name是接口里面的方法名-->
    12             <tx:method name="selectUser" propagation="REQUIRED"/>
    13             <tx:method name="addUser" propagation="REQUIRED"/>
    14             <tx:method name="delete" propagation="REQUIRED"/>
    15             <tx:method name="insert" propagation="REQUIRED"/>
    16             <tx:method name="*" propagation="REQUIRED"/>
    17         </tx:attributes>
    18     </tx:advice>
    19 
    20    <!--配置事务切入-->
    21     <aop:config>
    22         <!--定义一个切入点--><!--mapper下面的所有类 的所有方法-->
    23         <aop:pointcut id="trint" expression="execution(* com.rzk.mapper.*.*(..))"/>
    24         <!--要切入到哪里-->
    25         <aop:advisor advice-ref="txAdvice" pointcut-ref="trint"/>
    26     </aop:config>
  • 相关阅读:
    chapter4.6生成器
    chapter4.4、递归
    chapter4.3、函数执行流程
    chapter4.2、函数返回值
    直接插入排序
    打印三角型的练习
    杂记
    linux top命令
    makefile 中的 := , += ,?=
    makefile中的shell语法 || Makefile中的@
  • 原文地址:https://www.cnblogs.com/rzkwz/p/12658466.html
Copyright © 2011-2022 走看看