bug 总结 The bean ‘nacosRefreshProperties‘, defined in class path resource

这里写自定义目录标题


nacos配置中心启动时报错


APPLICATION FAILED TO START


Description:

The bean ‘nacosRefreshProperties’, defined in class path resource [com/alibaba/cloud/nacos/NacosConfigAutoConfiguration.class], could not be registered. A bean with that name has already been defined in URL [jar:file:/D:/App/Data/javaDev/MavenRepository/com/alibaba/cloud/spring-cloud-starter-alibaba-nacos-config/2.2.3.RELEASE/spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/com/alibaba/cloud/nacos/refresh/NacosRefreshProperties.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
————————————————

从报错可以看出是有多个同类型的Bean,第一个Bean已经注册,第二个Bean无法进行注册。报错中给出了解决方案。 通过这个配置 spring.main.allow-bean-definition-overriding=true 可以使后注册的Bean将覆盖已经注册的Bean。

可以参考的播客
https://blog.csdn.net/qq_41149775/article/details/127076008

最后面我发现是因为我启动类和com包放在了同一目录下才出现的问,放在和com包同一目录启动类会去搜索com包下面所有类,就会把已经过时的那个类nacosRefreshProperties 再加载一次,我把启动类放到com目录下面就没有出现这个问题了

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值