标签:eureka
EurekaClient@Qualifier("eurekaClient")
@Autowired
private EurekaClient eurekaClient;
public String dataServiceUrlByEurekaClient() {
InstanceInfo instance = eurekaClient.getNextServerFromEureka("spring-data-demo", false);
return instance.getHomePageUrl();
}
DiscoveryClient
@Autowired
private DiscoveryClient discoveryClient;
public String dataServiceUrlByDiscoveryClient() {
List<ServiceInstance> list = discoveryClient.getInstances("spring-data-demo");
if (list != null && list.size() > 0 ) {
return String.valueOf(list.get(0).getUri());
}
return null;
}
标签:eureka
原文地址:http://blog.51cto.com/881206524/2118415