Spring-cloud with Feign / Ribbon / Eureka - Unable to locate service instances

My bridging client is currently unable to discover service instances using Eureka. My config includes the following annotations:

@Configuration
@ComponentScan
@EnableAutoConfiguration
@EnableDiscoveryClient
@FeignClientScan

      

I have included the following dependencies (spring-cloud 1.0.0-BUILD-SNAPSHOT):

org.springframework.cloud:spring-cloud-starter-eureka
com.netflix.feign:feign-core
com.netflix.feign:feign-ribbon

      

As far as I can tell, the feign client uses ConfigurationBasedServerList

and therefore requires the addresses of the available service instances to be explicitly specified in the config file (property ribbon.serverList

).

However, everything works fine if I explicitly state:

ribbon.NIWSServerListClassName: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList

      

My test application also uses a Spring client based on a RestTemplate that is automatically configured to use the Eureka Ribbon implementation. The weird thing is that the Feign client works fine (i.e. finds service instances) if the RestTemplate is started first. It looks like the RestTemplate setting is doing some (static) initialization somewhere that benefits the feign client.

Am I missing something on how to set up Feig support?

+3


source to share





All Articles