Eureka Server-列出所有注册的实例
我有一个也是Eureka Server的Spring Boot应用程序。我想列出已注册到此Eureka服务器的所有实例。我该怎么做?
回答:
获取registry
使用,EurekaServerContextHolder.getInstance().getServerContext().getRegistry()
然后使用registry
列出所有Applications
PeerAwareInstanceRegistry registry = EurekaServerContextHolder.getInstance().getServerContext().getRegistry(); Applications applications = registry.getApplications();
applications.getRegisteredApplications().forEach((registeredApplication) -> {
registeredApplication.getInstances().forEach((instance) -> {
System.out.println(instance.getAppName() + " (" + instance.getInstanceId() + ") : " + response);
});
});
以上是 Eureka Server-列出所有注册的实例 的全部内容, 来源链接: utcz.com/qa/409737.html