【发布时间】:2015-02-21 14:15:32
【问题描述】:
我想在没有客户端负载均衡器 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
欢迎提出想法 :-)
【问题讨论】:
-
你为什么不想要
ribbon-loadbalancer? -
我刚刚为这个问题添加了一些上下文:它是关于 Eureka。
-
Ribbon 不依赖于 Eureka。您只需要告诉负载均衡器远程服务器的位置(例如,创建
@RibbonClient配置并将ServerList设置为@Bean)。这并不是说 Spring Cloud 中可能没有错误阻止您轻松执行此操作。 -
好吧,我没试过。但我的意思是我不想配置服务器列表,我只想使用纯 URL,就像使用
RestTemplate一样。
标签: java spring spring-cloud netflix-feign