基于XML文档的声明式事务配置

 1 <!-- 配置事务切面 -->
 2     <aop:config>
 3         <aop:pointcut 
 4             expression="execution(* com.atguigu.tx.component.service.BookShopServiceImpl.purchase(..))" 
 5             id="txPointCut"/>
 6         <!-- 将切入点表达式和事务属性配置关联到一起 -->
 7         <aop:advisor advice-ref="myTx" pointcut-ref="txPointCut"/>
 8     </aop:config>
 9     
10     <!-- 配置基于XML的声明式事务  -->
11     <tx:advice id="myTx" transaction-manager="transactionManager">
12         <tx:attributes>
13             <!-- 设置具体方法的事务属性 -->
14             <tx:method name="find*" read-only="true"/>
15             <tx:method name="get*" read-only="true"/>
16             <tx:method name="purchase" 
17                 isolation="READ_COMMITTED" 
18     no-rollback-for="java.lang.ArithmeticException,java.lang.NullPointerException"
19                 propagation="REQUIRES_NEW"
20                 read-only="false"
21                 timeout="10"/>
22         </tx:attributes>
23     </tx:advice>

猜你喜欢

转载自www.cnblogs.com/zhzcode/p/9753459.html