佳佳的博客
Menu
首页
The bean '*.FeignClientSpecification' could not be registered.
Posted by
佳佳
on 2020-12-23
IT
Spring
<!-- # The bean '*.FeignClientSpecification' could not be registered. --> <!-- the-bean-feignclientspecification-could-not-be-registered --> 当多个 `@FeignClient` 注解使用相同的 *name* 属性时,应用启动时报了如下错误: > The bean 'Provider_A.FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled. `@FeignClient` 的定义如下: ```java @FeignClient(name = MyServiceName.PROVIDER_A) public interface OneFeignClient { } @FeignClient(name = MyServiceName.PROVIDER_A) public interface AnotherFeingClient { } ``` 参考[这篇博客](https://blog.csdn.net/liuming690452074/article/details/107629519 "@FeignClient 的name重复定义"),只需要将 `@FeignClient` 注解的 *contextId* 属性指定为不同的值即可避免这个错误。 ```java @FeignClient(name = MyServiceName.PROVIDER_A, contextId = "one-context") public interface OneFeignClient { } @FeignClient(name = MyServiceName.PROVIDER_A, contextId = "another-context") public interface AnotherFeingClient { } ```
版权声明:原创文章,未经允许不得转载。
https://www.liujiajia.me/2020/12/23/the-bean-feignclientspecification-could-not-be-registered
“Buy me a nongfu spring”
« retrofit2 空响应时报 java.io.EOFException 异常
动态指定 Spring Boot 服务的名字 »
昵称
*
电子邮箱
*
回复内容
*
(回复审核后才会显示)
提交
目录
AUTHOR
刘佳佳
江苏 - 苏州
软件工程师
梦嘉集团