Spring FeignClient:如何配置类似Ribbon的负载均衡器

Spring FeignClient: How to configure a load balancer like Ribbon

我正在使用 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());
  }
}

我想了解如何将功能区添加到配置中。

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

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

没有尤里卡:

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

ribbon docs