java - Spring Cloud : How to use Feign without Ribbon

标签 java spring spring-cloud netflix-feign

我想在没有客户端负载均衡器 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/

相关文章:

java - 将 javax.mail.internet.MimeMessage 发送给非 ASCII 名称的收件人?

java - 使用 `where values in list`的Grails GORM 3.2.0查询

java - 分离前端和后端 Tomcat 应用程序?

spring - 如何覆盖Spring Cloud OAuth2客户端自动配置?

Spring boot 无法解析 aws 参数存储变量

java - 查询未检索到嵌入式 JDO 字段

java - 如何在 jsf 1.2 中使用 DynamicJasper

java - 在 Spring 中合并 java.util.Properties

java - 对于 Camel 路由输入端点的 JBoss 嵌入式 MQ 进行 jndi 查找时出现问题

spring-boot - 如何在@StreamListener 中添加日期条件