spring cloud 从服务注册组件获取服务实例
// 注入获取服务发现客户端
DiscoveryClient discoveryClient;
...
// 根据服务ID(spring application name)获取服务实例清单
List<ServiceInstance> instances = discoveryClient.getInstances("serviceId");
ServiceInstance instance = instances.get(0);
// 获取服务实例主机地址和端口号
restTemplate.getForObject("http://" + instance.getHost() + ":" + instance.getPort());