0

引用文档

@EnableDiscoveryClient 使应用程序成为 Consul“服务”(即它自己注册)和“客户端”(即它可以查询 Consul 以定位其他服务)。

如何配置使用 Feign 作为 REST 客户端并在 Consul 中查找服务实例但不在 Consul 注册应用程序本身的 Spring Boot 应用程序?

我试过了:

一个。各种组合

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

湾。根本不使用注解,只

@EnableFeignClients
// @EnableDiscoveryClient

在调用期间产生异常:

org.springframework.beans.factory.UnsatisfiedDependencyException:创建 org.springframework.cloud.consul.discovery.ConsulRibbonClientConfiguration 中定义的名称为 'ribbonServerList' 的 bean 时出错:通过方法 'ribbonServerList' 参数 1 表达的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有“org.springframework.cloud.consul.discovery.ConsulDiscoveryProperties”类型的合格 bean 可用:预计至少有 1 个有资格作为自动装配候选者的 bean。依赖注释:{}

我的FeingClient界面是这样注释的:

@FeignClient(value = "test-service")

其中 test-service 是在 Consul 中成功注册的服务。

4

1 回答 1

2

You should use @EnableDiscoveryClient(autoRegister=false).

于 2017-08-24T20:04:09.403 回答