spring boot - java.net.UnknownHostException during Eureka service discovery -
according blog https://spring.io/blog/2015/07/14/microservices-with-spring
was able run application without issues. in order:
- java -jar microservice-demo-0.0.1-snapshot.jar registration 1111
- java -jar microservice-demo-0.0.1-snapshot.jar accounts 2222
- java -jar microservice-demo-0.0.1-snapshot.jar web 3333
but when trying hit service through web application (http://localhost:3333/) uses http://accounts-service url access accounts service endpoints http://accounts-service/accounts/123456789 i'm getting error response:
response status: 500 (internal server error) cause: org.springframework.web.client.resourceaccessexception i/o error on request "http://accounts-service/accounts/123456789": accounts-service; nested exception java.net.unknownhostexception: accounts-service
when provide real address (http://localhost:2223/) of accounts service web server instead of http://accounts-service works there no service discovery in case.
the source code stored at: https://github.com/paulc4/microservices-demo
this issue due resttemplate no longer auto-created in brixton release-train (spring cloud 1.1.0.release), resttemplate not resolve http://accounts-service url using service discovery server.
was able fix issue after declaring resttemplate bean @loadbalanced follows:
@bean @loadbalanced public resttemplate resttemplate() { return new resttemplate(); }
I am still getting the same error even after using @loadbanced
ReplyDelete