spring事物配置注意事项

 <tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
   <tx:method name="sav*" propagation="REQUIRED" rollback-for="Exception"/>
   <tx:method name="del*" propagation="REQUIRED" rollback-for="Exception"/>
   <tx:method name="updat*" propagation="REQUIRED" rollback-for="Exception"/><!-- rollback-for回滚事物,果存在一个事务,则支持当前事务。如果没有事务则开启  -->
   <tx:method name="qry*" propagation="NOT_SUPPORTED" read-only="true" />
    <tx:method name="*" propagation="NOT_SUPPORTED" read-only="true" /> <!--必须要加propagation否则存在事物依然执行,NOT_SUPPORTED总是非事务地执行,并挂起任何存在的事务-->
  </tx:attributes> 
 </tx:advice>
 <!-- 事物切入 -->
 
 <aop:config>
  <aop:pointcut id="cut"
   expression="execution(* com.jb.pub.dao.impl.*.*(..))" />
  <aop:advisor advice-ref="txAdvice" pointcut-ref="cut" />
 </aop:config>

原文地址:https://www.cnblogs.com/qgc88/p/3303075.html