事务05-事务案例-转账:自动管理事务[使用AOP的实现](Spring 笔记015)暂记

自动生成代理[使用AOP自动生成代理:只进行了事务的管理]

1.配置管理器
2.配置事务详情
3.配置aop

.xml中①,②,③不变
④配置事务管理器
<bean id="txManager" class="org.~~.DataSourceTransactionManager">
<proprrty name="dataSource" ref="dataSource"> </property>   
</bean>
aop:如目标类中有ABCD四个方法,则可有4个切入点
<aop:config>
    <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.~.*Service*.*(..))"/>
</aop:config>  
详情配置:
<tx:advice id="txAdvice" transaction-manager="txManager"> 
    <tx:attributes>
    <tx:method name="transfer" propagation="RQUIRED" isolation="DEFAUIT" />
    </tx:attributes>
</tx:advice>  
注解配置略
</bean>

猜你喜欢

转载自blog.csdn.net/ResumeProject/article/details/112955163