1. 基于注解的事务配置
1 2 <bean id="transactionManager" 3 class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 4 5 <property name="dataSource" ref="dataSource">property> 6 bean> 7 8 10 <tx:annotation-driven transaction-manager="transactionManager" />
2. 基于XML的事务配置
1 2 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 3 4 <constructor-arg name="dataSource" ref="dataSource">constructor-arg> 5 bean> 6 7 <aop:config> 8 9 <aop:pointcut expression="execution(* *.checkout(..))" id="mypoint"/> 10 11 <aop:advisor advice-ref="myAdvice" pointcut-ref="mypoint" /> 12 aop:config> 13 14 <tx:advice id="myAdvice" transaction-manager="transactionManager"> 15 <tx:attributes> 16 17 <tx:method name="checkout" propagation="REQUIRED"/> 18 tx:attributes> 19 tx:advice>