Annotation-specified bean name conflicts with existing

问题说明

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}))

Guess you like

Origin blog.csdn.net/IndexMan/article/details/120699501