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

时间:2014-12-23 12:25:26

标签: java spring spring-cloud netflix-feign

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

@FeignClient提供普通网址始终会产生no loadbalancer found for ..,因此我尝试阻止Feign使用功能区:

Spring Cloud Netflix附带FeignRibbonClient,如果ILoadBalancer存在ribbon-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 已被破坏:

{{1}}

欢迎提示: - )

2 个答案:

答案 0 :(得分:17)

如果您想使用普通网址,请使用@FeignClient(value="http://example.com", loadbalance=false)

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

答案 1 :(得分:3)

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

@Bean
public Client feignClient() {
    return new Client.Default(null, null);
}