错误信息:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.***.***.StarterApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'discussController' for bean class [com.***.***.controller.wechat.DiscussController] conflicts with existing, non-compatible bean definition of same name and class [com.***.***.controller.web.DiscussController]
本人遇到这种问题,搞了半天,头疼。
搜来的解决办法:
1:加:@Controller("rename") ,感觉太繁琐。
2、重新定义Bean的命名策略,结果不起作用。
就请教了我司大牛,大牛一通操作,给出了完美解决方法,在这里感谢这位老师,也分享出来哈哈。
解决办法:
1、升级spring boot到2.2.7 升级spring到5.2.3以上
(我之前用的5.2.2,就差一个版本,就没有FullyQualifiedAnnotationBeanNameGenerator)
2、StarterApplication中添加
@ComponentScan(value = {"com.**.**.spring", ……(此处可配置多个包)}, nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class)
完美!