Feign Name already been defined

FeignClient使用相同名字时会提示重名并无法启动,可以通过添加contextId进行区分两个client

1
2
3
4
5
@FeignClient(contextId = "a", name = "User", configuration = FeignClientsConfiguration.class)
...

@FeignClient(contextId = "b", name = "User", configuration = FeignClientsConfiguration.class)
...

error

1
2
3
4
5
6
The bean FeignClientSpecification', defined in null, could not be registered. 
A bean with that name has already been defined in null and overriding is disabled.

Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException:
Invalid bean definition with name xxxx.FeignClientSpecification' defined in null:
Cannot register bean definition [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecificatio...