RestTemplate java.net.UnknownHostException

背景:公司内部系统的架构升级准备用微服务一套;记录遇到的坑。

错误信息:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; 
nested exception is org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://PROVIDER/add": PROVIDER;
nested exception is java.net.UnknownHostException: PROVIDER] with root cause java.net.UnknownHostException: PROVIDER

 看到有人说修改localhost 为本机IP 尝试也没有效果

 

上面是引起错误的代码。

这是正确的代码

加上@LoadBalanced

猜你喜欢

转载自www.cnblogs.com/wendao1996/p/11275742.html