繁体   English   中英

Spring Cloud:如何在没有 Ribbon 的情况下使用 Feign

[英]Spring Cloud: How to use Feign without Ribbon

我想在没有客户端负载均衡器 Ribbon 的情况下使用 Feign,因为我不想运行 Eureka,它需要分布式和高可用性。 相反,具有由 Route53 管理的内部 DNS 名称的内部 ELB 就可以了。

@FeignClient提供普通 URL 总是导致no loadbalancer found for .. ,所以我尝试阻止 Feign 使用 Ribbon:

Spring Cloud Netflix 随附FeignRibbonClient ,如果ILoadBalancer来自ribbon-loadbalancer ILoadBalancer则使用它。 但是,如果排除此依赖项,则FeignConfiguration已损坏:

Bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'apiVersionClient': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: feign.codec.Decoder org.springframework.cloud.netflix.feign.FeignConfiguration.decoder; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy

欢迎提出想法:-)

如果要使用普通 URL,请使用:

@FeignClient(value = "http://example.com", loadbalance = false)

使用 Brixton 发布系列,您将使用:

@FeignClient(url = "http://example.com", name = "example")

有点晚了,但是如果您提供自己的客户端 Bean,那么在研究此问题之后,LoadBalancerFeignClient 将不会被构建和使用,并且 Feign 打开跟踪自动配置仍然可以工作。

@Bean
public Client feignClient() {
    return new Client.Default(null, null);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM