0

Quoting the docs:

@EnableDiscoveryClient make the app into both a Consul "service" (i.e. it registers itself) and a "client" (i.e. it can query Consul to locate other services).

How can I configure a Spring Boot application that uses Feign as REST client and looks up service-instances in Consul but without registering the application itself at Consul?

I tried:

a. Various combinations of

spring.cloud.consul.enabled = true
spring.cloud.consul.discovery.enabled = true

b. Do not use the annotation at all, only

@EnableFeignClients
// @EnableDiscoveryClient

which produces an exception during the call:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ribbonServerList' defined in org.springframework.cloud.consul.discovery.ConsulRibbonClientConfiguration: Unsatisfied dependency expressed through method 'ribbonServerList' parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.consul.discovery.ConsulDiscoveryProperties' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

My FeingClient interface is annotated like this:

@FeignClient(value = "test-service")

where test-service is a successfully registered service in Consul.

user3105453
  • 1,881
  • 5
  • 32
  • 55

1 Answers1

2

You should use @EnableDiscoveryClient(autoRegister=false).

spencergibb
  • 24,471
  • 6
  • 69
  • 75