In microservice-based applications where services are usually distributed across servers or hosts, RESTful API has become second nature. With lots of these services interacting to complete a single transaction, creating REST client has become a challenge for developers. In this article, you will learn how to use FeignClient to build REST client to invoke services over HTTP in a declarative way.

FeignClient is a Spring Cloud annotation that is used to build REST client in a declarative way. Instead of conventionally writing codes calling the remote REST API, using FeignClient we only need to declare the client and define the signature of the REST API and let Spring do the building and provision the component at runtime.


Use the Spring Initializr website to generate a new Maven project with Spring Boot 2.x dependency or download the complete project from GitHub.

Import Spring Cloud Dependencies POM using Maven’s dependency management so our project could inherit all the artifacts versions in Spring Cloud.

<!-- spring-cloud -->

#spring #spring-cloud #spring-boot #microservices #cloud

Feign Client — Building REST Client in Microservices
8.65 GEEK