将
context:component-scan标记移至应用程序上下文xml可以解决事务行为的原因是:
<tx:annotation-driven />是一种后处理器,该处理器
@Transactional使用处理事务行为的AOP方法拦截器包装带注释的Bean方法。Spring后处理器仅在定义它们的特定应用程序上下文上运行。
在你的情况下,你已
<tx:annotation-driven />在应用程序上下文中定义了后处理器,而带有注释的Bean
@Transactional在servlet应用程序上下文中。因此,
<tx:annotation-driven />后处理器仅在应用程序上下文Bean上运行,而不在Servlet上下文Bean上运行。当
context:component-scan标签被移到应用程序上下文中时,
<tx:annotation-driven />后处理器会适当地包装其事务方法。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)