Friday, April 15, 2022

Feign Client Using Spring Boot | @EnableFeignClient | @FeignClient | FeignClient Spring Cloud



This is the video where I learnt Feign client, short and simple explanation.

1. Add dependency 

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
Add spring-cloud-starter-feign dependency to pom.xml 
2. Enable Feign Client 
@SpringBootApplicatispring-cloud-starter-feignon
@EnableFeignClients
Add Feign Client enable annotaton @EnableFeignClient in main class
3.Configer client url 
@FeignClient(value = "feignDemo",url = "http://localhost:8084/user/")
public interface FeignUtilService {
@GetMapping("name")
public String getName();

@GetMapping("city")
public String getCity();
}
All set to go....
This is the most simples way. But there are some other best practicess will update on the go. 
up to now this is what I know. :D 
Happy Coding guys cheers !!!

No comments:

Post a Comment

Feign Client Using Spring Boot | @EnableFeignClient | @FeignClient | FeignClient Spring Cloud

This is the video where I learnt Feign client, short and simple explanation. 1. Add dependency  <dependency> <groupId> ...