我怀疑这是一个问题,有人可以帮忙检查一下吗?
在我的 sideCar 应用程序中,我有 application.yml:
server:
port: 5678
spring:
application:
name: nodeservice
sidecar:
port: ${nodeServer.instance.port:3000}
health-uri: http://localhost:${nodeServer.instance.port:3000}/app/health.json
eureka:
instance:
hostname: ${host.instance.name:localhost}
leaseRenewalIntervalInSeconds: 5 #default is 30, recommended to keep default
metadataMap:
instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
在我的主要 spring 配置应用程序中,我有:
String url_node = "";
try {
InstanceInfo instance = discoveryClient.getNextServerFromEureka("nodeservice", false);
// InstanceInfo instance = discoveryClient.getNextServerFromEureka("foo", false);
url_node = instance.getHomePageUrl();
} catch (Exception e) {
}
现在我启动我的 nodeJS 服务器,我在 spring 应用程序中:
nodeService 的 url 是:http://SJCC02MT0NUFD58.local:3000/
这是完美的,但是在我关闭我的 nodeJS 服务器后, http://localhost:3000/app/health.json url 完全关闭了,但是,在主 java spring 应用程序中,我仍然在那里看到相同的输出。
因此,即使 NodeJS 服务不再可用,eureka 仍然会在内存中记住这一点。
我的配置有什么问题吗?
另一个问题是为什么 spring 发现的 url 是http://SJCC02MT0NUFD58.local:3000/,而不是http://localhost:3000?我已经将 Eureka.server.instance.host 配置为 localhost。
谢谢