Search code examples
javaspring-bootmicroservicesspring-cloud-feignfeign

Feignclient is not fetching the list of servers configured


I'm using Spring Boot 2.7.6 with Spring Cloud 2021.0.5, My Feignclient is not fetching the list of servers configured in application properties, printing following lines in log,

o.s.c.openfeign.FeignClientFactoryBean   : For 'MY-SERVICE' URL not provided. Will try picking an instance via load-balancing.

Instead of the configured URL it is taking default url i.e., http://MY-SERVICE/.. But I'm not using eureka server.

Feign Client:

@FeignClient(name= "MY-SERVICE", fallbackFactory = MyServiceClientFallbackFactory.class)
public interface MyServiceApiClient {
    ........
}

Aplication properties:

MY-SERVICE.ribbon.listOfServers=https://my-service-api.prod.cloud.net

Build.gradle

 implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
 implementation 'io.github.openfeign:feign-httpclient'
 implementation 'io.github.openfeign:feign-hystrix'

Solution

  • Spring-Cloud-Netflix-Ribbon has been deprecated and is not included in the 2020.0.0 release train. Spring-Cloud-LoadBalancer is the alternative.

    Updated my properties as following as per spring-cloud-loadbalancer:

    spring.cloud.discovery.client.simple.instances.MY-SERVICE[0].uri=https://my-service-api.prod.cloud.net
    

    Reference document to configure spring-cloud-openfeign : https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/