Spring aop切面插入事物回滚

2023-03-10,,


<!-- tx标签配置 事物-->
<tx:advice id="txadvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" rollback-for="Exception" />
<tx:method name="modify*" propagation="REQUIRED" rollback-for="Exception" />
<tx:method name="del*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="*" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice>
<!--aop切面插入事物-->
<aop:config>
<aop:pointcut id="daoMethod" expression="execution(* com.dao.*.*(..))"/>
<aop:advisor pointcut-ref="daoMethod" advice-ref="txadvice"/>
</aop:config>
execution中的 第一个*代表返回值,第二*代表dao下子包,第三个*代表方法名,(..)代表方法参数。
如果执行的过程中发生异常,则会事物回滚。

Spring aop切面插入事物回滚的相关教程结束。

《Spring aop切面插入事物回滚.doc》

下载本文的Word格式文档,以方便收藏与打印。