【问题标题】:Why can't the load balancer find needed microservice using eureka?为什么负载均衡器无法使用 eureka 找到所需的微服务?
【发布时间】:2020-07-09 08:51:21
【问题描述】:

clientui 使用来自 3 个微服务的数据为网页提供服务。

我成功设置了功能区以在 2 个“微服务产品”实例之间进行负载平衡。当我在 clientui 的 application.properties 中有这行 microservice-produits.ribbon.listOfServers=localhost:9001,localhost:9011 时,它可以工作。

现在我想让它工作,而不必对微服务 url 进行硬编码。

这是我尝试过的:

应用类:

和 RibbonClient 接口:

和 pom (clientui):

按照这些答案 (Load balancer does not have available server for client):

我尝试在 application.properties 中添加 fetchRegistry 行,并在 (clientui) pom.xml 中添加/删除 netflix-eureka-client 和 netflix-eureka-server 依赖项

不管我总是得到这个

有关信息,请参阅尤里卡控制台:

那么:有什么想法吗??

【问题讨论】:

  • 客户端 ui 应该有 eureka client starter no server
  • 是的,我都试过了

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


【解决方案1】:
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

而不是

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-netflix-eureka-client</artifactId>
</dependency>

解决了我的问题。

【讨论】:

    猜你喜欢
    • 2013-08-26
    • 2021-01-10
    • 2019-02-14
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    • 2017-09-27
    相关资源
    最近更新 更多