EurekaClient
創(chuàng)新互聯(lián)建站堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的怒江州網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
@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 list = discoveryClient.getInstances("spring-data-demo");
if (list != null && list.size() > 0 ) {
return String.valueOf(list.get(0).getUri());
}
return null;
}
RestTemplate
@Configuration
public class RestTemplateConfiguration {
@Bean
@LoadBalanced
RestTemplate restTemplate(){
return new RestTemplate();
}
}
@Autowired
private RestTemplate restTemplate;
@GetMapping("/restTemplateTest")
public String restTemplateTest(){
String str = restTemplate.getForObject("http://data-demo/demo/hello", String.class);
return str;
}