2017-02-23 56 views

回答

4

獲取使用registryEurekaServerContextHolder.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); 
     }); 
    });