Enabling Feign for an application

To include Feign in the project, we have to add to the dependencies the spring-cloud-starter-feign artifact or spring-cloud-starter-openfeign for Spring Cloud Netflix in minimal version 1.4.0:

<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-feign</artifactId></dependency>

The next step is to enable Feign for the application by annotating a main or a configuration class with @EnableFeignClients. This annotation will result in a search for all clients implemented in the application. We may also reduce the number of client used by setting the clients or basePackages annotation properties, for example, @EnableFeignClients(clients = {AccountClient.class, Product.class}) ...

Get Mastering Spring Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.