为了将非JVM应用程序集成到基于微服务的应用程序,我使用的是Spring Boot
Netflix Sidecar
概念的实现。我看了几个例子,并试图向他们学习,包括官方How to use database reserved keyword in Hibernate ?。不幸的是,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
中。我会很感激我在哪里弄错了。
答案 0 :(得分: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