我正在使用Spring FeignClient,并且必须支持Spring Ribbon提供的负载平衡。
@FeignClient(name = "testClient", url = "${test.url}", configuration = TestConfig.class)
@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes =
MediaType.APPLICATION_JSON_VALUE)
public interface TestClient {
}
public class TestConfig{
@Bean
public Client feignClient() {
return new ApacheHttpClient(getHttpClient());
}
}
我想了解如何将Ribbon添加到配置中。
答案 0 :(得分:1)
可以设置属性,像这样的配置:
hello-service:
ribbon:
eureka:
enabled: false
listOfServers: localhost:8090,localhost:9092,localhost:9999
没有尤里卡:
stores:
ribbon:
listOfServers: example.com,google.com