spring声明式事务以及配置

spring声明式事务以及配置

 

 

38 <!--     spring提供的事务管理器, -->
39     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
40         <property name="dataSource">
41             <ref bean="dataSource"/>
42         </property>
43     </bean>
44     <!--
45         通知 1、告诉spring容器,采用什么样的方法处理事务 2、告诉spring容器,目标方法应该采用什么样的事务处理策略
46     -->
47     <tx:advice id="tx" transaction-manager="transactionManager">
48         <tx:attributes>
49             <!--
50                 save开头的函数名 name规定方法 isolation 默认值为DEFAULT propagation 传播机制 REQUIRED
51             -->
52             <tx:method name="save*" read-only="false" />
53         </tx:attributes>
54     </tx:advice>
55 <!--     本来事务由程序员自己写并且当切面放入,但是这里spring提供了事务处理的通知方法,所以不用程序员写切面了 -->
56     <aop:config >
57         <aop:pointcut expression="execution(* cn.itcast.spring.jdbc.transaction.PersonService.*(..))" id="perform"/>
58         <aop:advisor advice-ref="tx" pointcut-ref="perform" />
59 <!--         指定了切面和通知 -->
60         <aop:aspect  ref="myException">
61             <aop:after-throwing method="defineException" pointcut-ref="perform" throwing="ex"/>
62         </aop:aspect>
63     </aop:config>

https://www.cnblogs.com/friends-wf/p/3786386.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值