我想在没有客户端负载均衡器 Ribbon 的情况下使用 Feign,因为我不想运行 Eureka,它需要分布式和高可用性。相反,具有由 Route53 管理的内部 DNS 名称的内部 ELB 就可以了。
向 @FeignClient
提供纯 URL 总是会导致 no loadbalancer found for ..
,所以我尝试阻止 Feign 使用 Ribbon:
Spring Cloud Netflix 附带 FeignRibbonClient
,如果 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")
关于java - Spring Cloud : How to use Feign without Ribbon,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27620338/