环境:
Spring Cloud + Nacos + OpenFeign
控制台报错:
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'xxx.FeignClientSpecification', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Process finished with exit code 1
原因分析:
Spring
在启动扫描时检测到同名的FeignClient
,导致初始化失败。
如何解决:
网上大多数教程都是说打开allow-bean-definition-overriding: true
,但是尼玛我复写之后,生效的bean不就只有一个了,真是误人子弟,正确办法是在@FeignClient
里面再多添加一个专属的contextId
。