<aop:config>
<!-- 切入点指明了在执行Service的所有方法时产生事务拦截操作 -->
<aop:pointcut id="userManagerPointcut"
expression="execution(* com.renderbus.*.service.*ServiceImpl.*(..))" />
<!-- 定义了将采用何种拦截操作,这里引用到 txAdvice -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="userManagerPointcut" />
</aop:config>
<!-- 需要引入tx的命名空间 -->
<!-- 这是事务通知操作,使用的事务管理器引用自 transactionManager -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 指定哪些方法需要加入事务,这里懒惰一下全部加入,可以使用通配符来只加入需要的方法 -->
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="remove*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="new*" propagation="REQUIRED" />
<tx:method name="query*" read-only="true" />
<tx:method name="load*" read-only="true" />
<tx:method name="get*" read-only="true" />
</tx:attributes>
</tx:advice>
可以参考这个url地址:http://www.cnblogs.com/Angi/articles/2007552.html
spring 配置事务的几种方式
最新推荐文章于 2020-09-07 19:57:34 发布