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>