spring-bootfeign

Create FeignClient With Constructor


I know that we can create FeignClient like:

@FeignClient(value = "service-A-client", url = "${service-A-client.url}")
public interface ServiceAClient {

 @PostMapping(value = "/service-A/v1/resource")
    Response getResource(RequestPojo request);
 
}

But I wonder whether I can create it via constructor or not:

public interface ServiceAClient {

 @PostMapping(value = "/service-A/v1/resource")
    Response getResource(RequestPojo request);
 
}

public class FeignConfig {
     
    @Bean
    public ServiceAClient service() {
        return new ... ? is it possible?
    }
}

Solution

  • Thanks to @JAsgarov solved with Feign Builder API

    public Feign.Builder feignBuilder() {
            return Feign.builder();
        }