We have a specific config in FeignClientConfiguration.java:
@Configuration
public class FeignClientConfiguration {
@Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor(username, password);
}
}
Then in one feign client in one package we have the following so that it will use the above configuration:
@FeignClient(name = "my-client", url = "https://myurl/", configuration = FeignClientConfiguration.class)
public interface MyFeignClient {
@RequestMapping(...
}
In a separate feign client, which has a completely different purpose and endpoint, we have:
@FeignClient(name = "some-other-client", url = "https://different-url/")
public interface OtherFeignClient {
@RequestMapping(...
}
The problem is that the second one is also getting the config from FeignClientConfiguration for some reason. How do we restrict a configuration class to a single feign client?
We have a specific config in FeignClientConfiguration.java:
@Configuration
public class FeignClientConfiguration {
@Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor(username, password);
}
}
Then in one feign client in one package we have the following so that it will use the above configuration:
@FeignClient(name = "my-client", url = "https://myurl/", configuration = FeignClientConfiguration.class)
public interface MyFeignClient {
@RequestMapping(...
}
In a separate feign client, which has a completely different purpose and endpoint, we have:
@FeignClient(name = "some-other-client", url = "https://different-url/")
public interface OtherFeignClient {
@RequestMapping(...
}
The problem is that the second one is also getting the config from FeignClientConfiguration for some reason. How do we restrict a configuration class to a single feign client?
Share Improve this question asked Nov 25, 2024 at 17:20 John LittleJohn Little 12.2k25 gold badges107 silver badges179 bronze badges1 Answer
Reset to default 0I found a solution. It turns out if you add @Configuration on the feign config class, it adds it to ALL feign clients, regardless.
The solution was to remove @Configuration, then rely on the @FeignClient(..configuration = FeignClientConfiguration.class) to link them.
The popular examples on the internet do both, which appears to be wrong.