I have a problem with a spring @FeignClient
. I've updated one of our services to Spring Boot 3 with all corresponding libraries, so now we have open feign v4 instead of 3 previously. And it looks like it behaves differently as our tests fail now because @FeignClient
sends requests using wrong url adding a value from name
field to url. Here's an example:
@FeignClient(name = "my-client", url = "${my-client-api.url}")
public interface MyClient {
@PostMapping
MyResponse getInfo(@RequestHeader Map<String, String> headers,
@RequestBody InfoRequest infoRequest);
}
my-client-api
comes from configuration, for tests it's just http://localhost:${wiremock.server.port}
. So, with SB2 and client v3 everything was ok, it just sent a request to the designated url. But with SB3 and client v4 it adds @FeignClient
's name
value to the url, i.e. it sends requests to http://localhost:${wiremock.server.port}/my-client
. Could anyone explain me why it happens and how to make it send requests without adding a name to a url?
Since there's no answer, I'll answer myself. Maybe I don't fully understand how feign client works, but in case of tests a lazy attributes resolution mode helped me. In spring's manual it's written that this mode should be used for tests:
spring:
cloud:
openfeign:
lazy-attributes-resolution: true