I am trying to call a zuul
enabled server through RestTemplate
by directly giving the URL.
For example: restTemplate.getForObject("http://localhost:8090/emp-api", Employee[].class);
But it is giving an error to me:
java.lang.IllegalStateException: No instances available for localhost at org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute(RibbonLoadBalancerClient.java:90) ~[spring-cloud-netflix-core-1.2.3.RELEASE.jar:1.2.3.RELEASE]
Question in detail : I am having four projects (Github link (branch-master): https://github.com/vickygupta0017/microservice-poc)
- microservice-server (eureka-server) port:8080
- microservice-producer (Rest-api) port:8086
- zuul-gatewayproxy (zuul-server) port:8090
microservice-consumer (spring-mvc) port:8087
If I am calling zuul server
directly from browser("http://localhost:8090/emp-api), then it is redirecting the request to producer successfully.
But if I am calling this URL from the consumer through RestTemplate
then it is giving me this error.
For Information : If I am not using zuul sever then I am able to call 'microservice-producer' from 'microservice-consumer' using RestTemplate
successfully.