Spring Cloud:如何使用没有功能区的Feign

Kon*_*ann 14 java spring spring-cloud netflix-feign

我想在没有客户端负载均衡器功能区的情况下使用Feign,因为我不想运行需要分发且高度可用的Eureka.相反,具有由Route53管理的内部DNS名称的内部ELB可以正常运行.

提供@FeignClient始终导致的纯URL no loadbalancer found for ..,因此我尝试阻止Feign使用Ribbon:

春云Netflix的自带FeignRibbonClient,用于如果ILoadBalancerribbon-loadbalancer存在.但是,如果排除此依赖关系,则会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
Run Code Online (Sandbox Code Playgroud)

欢迎提示:-)

spe*_*ibb 19

如果要使用普通URL @FeignClient(value="http://example.com", loadbalance=false)

使用Brixton发布列车 @FeignClient(url="http://example.com", name="example")

  • 谢谢@spencergibb.我也想通过`ribbon.eureka.enabled = false`我可以禁用功能区 (3认同)
  • @spencergibb`loadbalance`似乎不再适用于`@FeignClient`(Spring Boot 1.3.5,Brixton SR1发布).任何替代品? (2认同)
  • 格林威治版本没有“负载平衡”属性? (2认同)

小智 5

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

@Bean
public Client feignClient() {
    return new Client.Default(null, null);
}
Run Code Online (Sandbox Code Playgroud)