背景:
微服务环境,配置文件为bootstrap.yml + application-xxx.yml
启动报错:
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
[2022-06-17 15:22:15.205]-[default]-[172.16.1.13]-[SystemUser]-[ERROR]-[]-[main]-[org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter] ==>
APPLICATION FAILED TO START
Description:
The bean ‘feignDecoder’, defined in class path resource [com/xxx/component/custom/feign/FeignCodeConfig.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/openfeign/FeignClientsConfiguration.class] and overriding is disabled.
经过排查后,在配置文件中增加了application.yml解决了问题,估计是bootstrap.yml里不能生效了的原因,application.yml:
spring:
main:
allow-bean-definition-overriding: true
profiles:
#启用的环境配置 dev表示 使用 application-dev.yml
active: dev