Spring   发布时间:2022-04-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在Spring注释配置中使用@Service与@Service进行交互 大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我只是听不懂.是否通过@transaction批注将@serviced标记为@serviced并在@ContextComponent中在应用程序上下文中注册的bean,以提供事务支持

这工作正常:

    public class LOCATIOnManagerImpl implements LOCATIOnManager {

        @transactional
        public void saveLOCATIOn(LOCATIOn LOCATIOn) {

        }

    }

//config class

@Bean
public LOCATIOnManager LOCATIOnManager() {
    return new LOCATIOnManagerImpl();
}

这不是:

@service
public class LOCATIOnManagerImpl implements LOCATIOnManager {

    @transactional
    public void saveLOCATIOn(LOCATIOn LOCATIOn) {

    }

}
最佳答案
问题可能是您的@transactional带注释的类位于servlet上下文中.如果您具有< context:component-scan="">在servlet应用程序上下文配置中,而Spring AOP拦截器在根应用程序上下文中配置.

解决方案是将带@service注释的类移至根Web应用程序应用程序上下文.

参见Spring @Transactional not working.

Servlet和Web App Root上下文之间的区别:
Difference between applicationContext.xml and spring-servlet.xml in Spring Framework.

大佬总结

以上是大佬教程为你收集整理的在Spring注释配置中使用@Service与@Service进行交互 全部内容,希望文章能够帮你解决在Spring注释配置中使用@Service与@Service进行交互 所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。