I have a whole bunch of Feign clients that uses a shared configuration(MyFeignConfiguration.class
):
@FeignClient(name = "clientA", url = "http://serviceA.com", fallbackFactory = ServiceAFallbackFactory.class, configuration = MyFeignConfiguration.class)
@FeignClient(name = "clientB", url = "http://serviceB.com", fallbackFactory = ServiceBFallbackFactory.class, configuration = MyFeignConfiguration.class)
@FeignClient(name = "clientC", url = "http://serviceC.com", fallbackFactory = ServiceCFallbackFactory.class, configuration = MyFeignConfiguration.class)
However, for a new client, I want to change the underlying Http Client that is used to OkHttp one. In the MyFeignConfiguration
class, I can add the following:
@Configuration
class MyFeignConfiguration {
@Bean
public Client getClient() {
return OkHttpClient() // use the OkHttp client
}
@Bean
public ErrorDecoder getErrorDecoder() {
//... existing configs
}
However, now all of the clients are using this OkHttp client. How do configure the new feign client so that only it is using the OkHttp client? Also, I still need to use the existing default configs(like the ErrorDecoder
) from my main MyFeignConfiguration
class.