@Resource private DiscoveryClient discoveryClient; #spring的包 @GetMapping(value="/payment/discovery") public Object discovery(){ List<String> services = discoveryClient.getServices(); services.forEach(item -> { log.info("***********"+item); }); List<ServiceInstance> instances = discoveryClient.getInstances("CLOUD-PAYMENT-SERVICE"); instances.forEach(item ->{ log.info("====="+item.getServiceId() + "\t"+item.getHost() + "\t" + item.getPort() + "\t" + item.getUri()); }); return discoveryClient; }