Spring Cloud:如何在没有 Ribbon 的情况下使用 Feign [英] Spring Cloud: How to use Feign without Ribbon
问题描述
我想在没有客户端负载均衡器 Ribbon 的情况下使用 Feign,因为我不想运行 Eureka,它需要分布式和高可用性.相反,具有由 Route53 管理的内部 DNS 名称的内部 ELB 就可以了.
I would like to use Feign without client-side loadbalancer Ribbon because I don't want to run Eureka, which would need to be distributed and highly available. Instead internal ELBs with internal DNS names managed by Route53 will do just fine.
向 @FeignClient
提供普通 URL 总是导致 找不到负载均衡器 ..
,所以我尝试阻止 Feign 使用 Ribbon:
Providing plain URLs to @FeignClient
always results in no loadbalancer found for ..
, so I tried preventing Feign from using Ribbon:
Spring Cloud Netflix 带有 FeignRibbonClient
,如果 ribbon-loadbalancer
中的 ILoadBalancer
存在,则使用它.但是,如果排除此依赖项FeignConfiguration
被破坏:
Spring Cloud Netflix comes with FeignRibbonClient
, which is used if ILoadBalancer
from ribbon-loadbalancer
is present. However, if this dependency is excluded FeignConfiguration
is broken:
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 使用:
If you want to use a plain URL use:
@FeignClient(value = "http://example.com", loadbalance = false)
您将使用 Brixton 发布系列:
With the Brixton release train you would use:
@FeignClient(url = "http://example.com", name = "example")
这篇关于Spring Cloud:如何在没有 Ribbon 的情况下使用 Feign的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!