会出现下面的错误:
The bean 'xxxx.FeignClientSpecification', defined in null, could not be registered.
A bean with that name has already been defined in null and overriding is disabled
解决方法:
spring:
main:
allow-bean-definition-overriding: true
下面的是我用的cloud的版本
<spring-cloud.version>Greenwich.RC2</spring-cloud.version> <spring-boot.version>2.1.1.RELEASE</spring-boot.version>
在SpringBoot 2.1之前,这个配置默认就是true,而在2.1做了更改。
设置为true后,因为FeignClientSpecification的原因,FeignClient注解的configuration参数会被覆盖
参考:
https://blog.csdn.net/neosmith/article/details/82349449
个人觉得Stackoverflow中有位大佬说的不错:
https://stackoverflow.com/questions/53103991/cant-stat-app-after-updating-springboot-from-2-0-6-release-to-2-1-0-release
别的情况下也可能会因为Bean名重复引起该错误,更佳的解决方案是尽可能避免去定义相同的Bean名。
而Feign远程调用服务因为业务需求出现在不同在接口上使用相同的服务名,将allow-bean-definition-overriding设置为true,如果在其他情况下没有重复Bean名,那么受影响的应该就只是Feign的configuration(然而configuration我都没另外做配置,覆盖也不影响