当前位置:网站首页>Service Discovery @EnableDiscoveryClient

Service Discovery @EnableDiscoveryClient

2022-08-10 00:56:00 A wind light cloud light

@[email protected]@EnableDiscoveryClient //Service discoverypublic class PaymentMain8001{public static void main(String[] args){SpringApplication.run(PaymentMain8001.class,args);}}
 @Resourceprivate DiscoveryClient discoveryClient;@GetMapping(value = "/payment/discovery")public Object discovery(){List services = discoveryClient.getServices();for (String element : services) {System.out.println(element);}List instances = discoveryClient.getInstances("CLOUD-PAYMENT-SERVICE");for (ServiceInstance element : instances) {System.out.println(element.getServiceId() + "\t" + element.getHost() + "\t" + element.getPort() + "\t"+ element.getUri());}return this.discoveryClient;}

原网站

版权声明
本文为[A wind light cloud light]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208092245503603.html