我正在使用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添加到配置中。

最佳答案

您可以像这样设置配置属性:

hello-service:
  ribbon:
    eureka:
      enabled: false
    listOfServers: localhost:8090,localhost:9092,localhost:9999


没有尤里卡:

stores:
  ribbon:
    listOfServers: example.com,google.com


ribbon docs

10-04 18:58