DiscoveryClient服务发现
发现注册的服务信息
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13
| @GetMapping("/discovery") public Object discovery(){ List<ServiceInstance> saxon = client.getInstances ("SAXON"); for (ServiceInstance serviceInstance : saxon) { System.out.println ("serviceInstance=====>"+serviceInstance.getHost ()); System.out.println ("serviceInstance=====>"+serviceInstance.getInstanceId ()); System.out.println ("serviceInstance=====>"+serviceInstance.getServiceId ()); System.out.println ("serviceInstance=====>"+serviceInstance.getPort ()); System.out.println ("serviceInstance=====>"+serviceInstance.getUri ()); System.out.println ("serviceInstance=====>"+serviceInstance.getMetadata ()); } return this.client; }
|
输出信息
1 2 3 4 5 6
| serviceInstance=====>Saxon serviceInstance=====>saxonmo serviceInstance=====>SAXON serviceInstance=====>8001 serviceInstance=====>http://Saxon:8001 serviceInstance=====>{management.port=8001}
|
网页获得代码:
1
| {"discoveryClients":[{"services":["saxon"],"order":0},{"services":[],"order":0}],"services":["saxon"],"order":0}
|
获得我们服务注册中心的东西,标志是名字;就是application.name;