Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot二次代理问题 #3096

Open
eryanwcp opened this issue Feb 27, 2019 · 2 comments · May be fixed by #6132
Open

Spring Boot二次代理问题 #3096

eryanwcp opened this issue Feb 27, 2019 · 2 comments · May be fixed by #6132

Comments

@eryanwcp
Copy link
Contributor

问题参考 #2770
个人分析:这是由于Spring Boot 默认配置造成的:spring.aop.auto=true (等同于@EnableAspectJAutoProxy)。
这个与DefaultAdvisorAutoProxyCreator的再次注入有冲突。
这个bug不仅会导致aop的统计有问题,而且可能还会导致事务的两次代理,等等。

个人实践,添加以下代码即可解决:(如有其它方法,请指出!)
com.alibaba.druid.spring.boot.autoconfigure.stat.DruidSpringAopConfiguration

@ConditionalOnProperty(name = "spring.aop.auto",havingValue = "false")

    @Bean
    @ConditionalOnProperty(name = "spring.aop.auto",havingValue = "false")
    public DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator() {
        DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
        advisorAutoProxyCreator.setProxyTargetClass(true);
        return advisorAutoProxyCreator;
    }
@yangdq1
Copy link

yangdq1 commented Oct 30, 2019

这个问题除了不加aop-patterns与改源码外,还有什么解决方案么,现在升级spring boot 2.1.5以上版本后,二次代理会导致 存在循环依赖的 服务无法启动,有类似问题解决方案否(别说改掉循环依赖),谢谢

@linghengqian
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants