@SpringBootApplication
@EnableDiscoveryClient
public class eurekaClient1 {
public static void main(String[] args) {
SpringApplication.run(eurekaClient1.class, args);
}
@Bean
@LoadBalanced
RestTemplate restTemplate(){
return new RestTemplate();
}
}
@RestController
public class ServiceInstanceRestController {
@Autowired
private DiscoveryClient discoveryClient;
@Autowired
private RestTemplate restTemplate;
@RequestMapping("/service-instances/{applicationName}")
public List<ServiceInstance> serviceInstances(@PathVariable String applicationName) {
return this.discoveryClient.getInstances(applicationName);
}
@RequestMapping("/")
public String sayhello() {
String forObject = restTemplate.getForObject("http://HYSTRIXTEST/", String.class);
System.out.println(forObject);
return forObject;
}