spring.main.allow-bean-definition-overriding: true 改配置不能放到nacos配置中心中

1.展示一下异常(nacos中已经配置spring.main.allow-bean-definition-overriding=true依然报错)

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-03-07 16:28:45.687 ERROR 1853 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'team-chat.FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled.

Action:

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

2.解决方案:

spring.main.allow-bean-definition-overriding=true放置到配置nacos的配置文件中

举例: 项目的环境有(本地,开发,测试,生产)

分别是: bootstrap-local.yml、bootstrap-dev.yml、bootstrap-test.yml、bootstrap-prod.yml

bootstrap-dev.yml的nacos配置如下:

spring:
  application:
    name: team-talk #服务名称
  main:
    allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
  cloud:
    nacos:
      discovery:
        server-addr:***.mse.aliyuncs.com:8848,6443,9848
      config: # 拉取配置中心需要改成application配置文件,优先加载
        file-extension: yaml # 配置文件格式
        group: TEAM_GROUP
        server-addr: ***.mse.aliyuncs.com:8848,6443,9848
        enable-remote-sync-config: true

测试环境和生产环境都是同样的配置,spring.main.allow-bean-definition-overriding=true不放置在nacos配置中心中.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。