@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() + " "+item.getHost() + " " + item.getPort() + " " + item.getUri()); }); return discoveryClient; }