【问题标题】:zuul multiple urls one pathzuul 多个 url 一个路径
【发布时间】:2017-11-09 02:07:15
【问题描述】:

您好,我有一个可以有多个服务器的路由...

我尝试了以下方法,但没有成功:

zuul.routes.example.path=/example/**
zuul.routes.example.serviceId=example
example.ribbon.eureka.enabled=false
example.ribbon.eureka.listOfServers=http://127.0.0.1/metrics,http://127.0.0.1/info

这只是返回以下错误:

原因:com.netflix.client.ClientException:负载均衡器没有可用于客户端的服务器:示例

我在大多数路线上都使用尤里卡,但尤其是这条路线我不能使用尤里卡。

是否可以让zuul在两个url之间进行负载均衡?

已解决

下面的答案通过配置解决了这个问题,但是我会提到我使用的是 spring-boot-starter-parent,我还必须将依赖管理升级到 Camden.SR7

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
<!--         <version>Brixton.SR5</version> -->
        <version>Camden.SR7</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

【问题讨论】:

    标签: spring-cloud netflix-zuul netflix-ribbon


    【解决方案1】:

    是的,你可以。请尝试以下属性,而不是您的。

    zuul.routes.example.path=/example/**
    zuul.routes.example.serviceId=example
    example.ribbon.NIWSServerListClassName=com.netflix.loadbalancer.ConfigurationBasedServerList
    example.ribbon.listOfServers=http://127.0.0.1/metrics,http://127.0.0.1/info
    

    【讨论】:

    • 这是否意味着我不能对某些人使用尤里卡而对其他人使用本地配置? - github.com/spring-cloud/spring-cloud-netflix/issues/564
    • 上述链接问题是一个非常古老的问题。以上属性对我有用。只有示例服务适用于本地配置,其他服务适用于 eureka。
    • 嗯,如果我添加ribbon.eureka.enabled=false 它可以工作:/你的类路径上有eureka吗?
    • 当然。我有尤里卡。你用的是哪个版本的spring cloud?
    • 1.2.3.RELEASE 我想会尝试更新的版本
    猜你喜欢
    • 2019-06-11
    • 2017-11-13
    • 1970-01-01
    • 2017-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多