Search code examples
springspring-bootspring-cloudspring-cloud-feignfeign

How to inject Feign Client with out using Spring Boot and call a REST Endpoint


I have two Java processes - which get spawned from the same Jar using different run configurations

Process A - Client UI component , Developed Using Spring bean xml based approach. No Spring Boot is there.

Process B - A new Springboot Based component , hosts REST End points.

Now from Process A , on various button click how can I call the REST end points on Process B using Feign Client.

Note - Since Process A is Spring XML based , right at the moment we can not convert that to Spring boot. Hence @EnableFeignClients can not be used to initialise the Feign Clients

So Two questions

1) If the above is possible how to do it ?

2) Till Process A is moved to Spring boot - is Feign still an easier option than spring REST template ?


Solution

  • You are able to just initialise Feign in any code (without spring) just like in the readme example:

    public static void main(String... args) {
        GitHub github = Feign.builder()
                         .decoder(new GsonDecoder())
                         .target(GitHub.class, "https://api.github.com");
    ...
    }
    

    Please take a look at the getting started guide: feign on github