问题说明
Annotation-specified bean name conflicts with existing,non-compatible bean definition of same name and class
翻译一下,大概就是:
使用的注解发现了2个同名的bean导致了冲突。
原因分析
我用的springboot依赖了2个第三方jar,里面分别有一个AuditConfig bean,我又不能去修改他们,因为不是我维护的。问题清楚了下面解决吧!
问题解决
既然不能去改变第三方依赖,那就尝试在我应用启动的时候排除掉那个不用的bean即可,例如我的做法:
@ComponentScan(basePackages = {"com.xx.xx.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {AuditConfig.class}))

本文讲述了如何在Spring Boot应用中遇到同名bean冲突时,通过@ComponentScan排除指定bean来解决问题,避免修改第三方依赖。
924

被折叠的 条评论
为什么被折叠?



