我是靠谱客的博主 激情战斗机,最近开发中收集的这篇文章主要介绍ConflictingBeanDefinitionException异常,Annotation-specified bean name ‘redisConfig‘ for bean class,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

项目在启动的时候会报错:
Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name ‘redisUtil’ for bean class [com.sinoccdc.devops.utils.common.RedisUtil] conflicts with existing, non-compatible bean definition of same name and class [com.sinoccdc.devops.utils.tracelog.RedisUtil]

关键点在于这个xx的类,名称重复了
Annotation-specified bean name ‘xx’ for bean class [xxx] conflicts with existing, non-compatible bean definition of same name and class[xxx]

原因:
spring中有相同名称的类时,使用时没有明确指定bean名称,则会抛出异常:

最简单的方法:
在项目中查找重复的Bean名称,将部分重复的bean名称更改一下;更改原则是:公共包下面的Bean保持原名称,自己模块下重复的Bean名称改为新的名称即可

最后

以上就是激情战斗机为你收集整理的ConflictingBeanDefinitionException异常,Annotation-specified bean name ‘redisConfig‘ for bean class的全部内容,希望文章能够帮你解决ConflictingBeanDefinitionException异常,Annotation-specified bean name ‘redisConfig‘ for bean class所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(33)

评论列表共有 0 条评论

立即
投稿
返回
顶部