service 事务

事务策略--sevice 回滚上一层

<!-->propagation==SUPPORTS   支持当前事务,如果不存在就不使用事务<-->

<!-->propagation==REQUIRED   支持当前事务,如果不存在就不使用事务—支持当前事务,如果不存在就新创建一个事务。这是最常用的选择。<-->

<!-- 定义事务策略 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!--所有以query开头的方法都是只读的 -->
<tx:method name="search*" propagation="SUPPORTS" read-only="true" />
<tx:method name="query*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="*" propagation="REQUIRED" read-only="false"/>
<!--其他方法使用默认事务策略 -->
</tx:attributes>
</tx:advice>

<aop:config>

<aop:pointcut id="myPointcut" expression="execution(* com.yd.*.*.service.*.*(..))" />
<!--将定义好的事务处理策略应用到上述的切入点 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="myPointcut" />
</aop:config>

原文地址:https://www.cnblogs.com/Darkqueen/p/13685487.html