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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM