【问题标题】:Spring sidecar application failing to discover the Eureka serverSpring Sidecar 应用程序无法发现 Eureka 服务器
【发布时间】:2018-11-19 20:56:53
【问题描述】:

为了将非 JVM 应用程序集成到基于微服务的应用程序中,我使用了 Netflix Sidecar 概念的 Spring Boot 实现。我看过几个例子,并试图从中学习,包括官方的spring documentation。不幸的是,sidecar 应用程序无法发现Eureka 服务器。运行应用程序后抛出以下错误:

DiscoveryClient_VISITS-SIDECAR/localhost:visits-sidecar:0 - registration failed There is no known eureka server; cluster server list is empty

这里是sidecar应用的主类:

@SpringBootApplication
@EnableSidecar

public class VisitsSidecarApplication {

public static void main(String[] args) {
    SpringApplication.run(VisitsSidecarApplication.class, args);
   }
}

必要的依赖关系也包含在pom 中。我将不胜感激任何关于我哪里出错的指示。

【问题讨论】:

    标签: spring-boot microservices netflix-eureka spring-cloud-netflix


    【解决方案1】:

    我意识到我的错误,我的 application.yml 文件配置错误,因此 eureka 服务器端点不正确。 defaultZone 值是 localhost:8761 而不是 http://localhost:8761/eureka/。我立即对其进行了更改,边车应用程序发现了服务器。这是正确配置的application.yml 文件:

    server:
    port: 9100
    spring:
        application:
          name: vets-sidecar
    eureka:
      instance:
        hostname: localhost
      client:
        serviceUrl:
          defaultZone: http://localhost:8761/eureka/
    sidecar:
      port: 9102
      health-uri: http://localhost:${sidecar.port}/health
    

    【讨论】:

      猜你喜欢
      • 2019-05-11
      • 2017-02-20
      • 2018-04-15
      • 2016-05-26
      • 1970-01-01
      • 2020-05-22
      • 1970-01-01
      • 2019-02-11
      • 2016-06-30
      相关资源
      最近更新 更多