这里写自定义目录标题
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目录下面就没有出现这个问题了