I use a library that defines some OpenFeign clients using spring-cloud-openfeign. I need to add an interceptor to these clients to add an authorization header without changing the library code.
So far I just defined the interceptor as a Spring bean and everything worked. But now I added another OpenFeign client that needs a different interceptor, which I defined using the configuration
attribute of the @FeignClient
annotation. My problem is that the new client now gets both interceptors.
I tried configuring the first interceptor using application properties instead, but the interceptor needs to get another bean injected, which seems to require defining it as a bean, which would add it to the second client again.
I also tried to find an equivalent to CDI's @Typed
annotation so that the interceptor would only be found when looking for it's concrete class but not when looking for the RequestInterceptor
interface, but couldn't find any.
Is there any way to add a configuration to an OpenFeign client defined in a library such that it does not affect any other clients?