spring事务失效

问题描述:

   springMVC应用,基于注解的事务管理,事务管理不失效,当service发生异常时,事务无法回滚。经调查测试,发现问题在于父子容器造成的,因为Controller在子容器中,service bean在父容器中,而<tx:annotation-driven transaction-manager="transactionManager"/>定义在父容器中,那么controller中注入的servcie 是没有事务增强处理的。

解决办法:将<tx:annotation-driven transaction-manager="transactionManager"/>定义到子容器即可。

父上下文不能对子上下文进行AOP

猜你喜欢

转载自xls9577087.iteye.com/blog/2149560