解决spring boot org.springframework.context.annotation.ConflictingBeanDefinitionException异常的方法,亲测有效

📖 作者简介:在职Java架构师,分享Java、架构相关知识

📖 多年工作总结:Java学习路线总结,逆袭Java架构师

📖 技术交流:定期更新Java硬核干货,不定期送书活动、助你实现技术飞跃

📖 关注公众号【程序技术圈】,回复 面试题 ,获取《108道Java经典面试题总结(附答案)》pdf,复习方便,面试利器!

spring boot org.springframework.context.annotation.ConflictingBeanDefinitionException异常的正确解决方法

最近运行旧项目时报出了这个异常,异常信息如下:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com..Application]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean **name 'DeExecutor' for bean class [com.Executor] conflicts with existing, non-compatible bean definition of same name and class** [com.r.Executor]
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:271)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:91)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:692)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:530)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230)
	at com.main(Application.java:11)
Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'DefRuleExecutor' for bean class [com..Executor] conflicts with existing, non-compatible bean definition of same name and class [com.Executor]
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate(ClassPathBeanDefinitionScanner.java:348)
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:286)
	at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132)
	at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:288)
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202)
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170)
	... 13 common frames omitted

解决方式:

annotation.ConflictingBeanDefinitionException说明是系统内的注解错误,在继续往下看bean definition of same name 定义了相同的bean

说明项目中的service及component里面写的名称是有重复的,去掉重复的名称后就可以了。

📖 作者简介:在职Java架构师,分享Java、架构相关知识

📖 多年工作总结:Java学习路线总结,逆袭Java架构师

📖 技术交流:定期更新Java硬核干货,不定期送书活动、助你实现技术飞跃

📖 关注公众号【程序技术圈】,回复 面试题 ,获取《108道Java经典面试题总结(附答案)》pdf,复习方便,面试利器!

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值