错误集锦
2019-10-22 16:41:28.738 ERROR 41220 --- [nio-8010-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: port out of range:80001] with root cause
解决:服务消费者在调用服务提供者时,IP端口后少了一个路径分隔符。如下图
错误示例:
正确示例:@GetMapping("/user/{id}") public User findById(@PathVariable Long id) { return this.restTemplate.getForObject("http://localhost:8000" + id, User.class); }@GetMapping("/user/{id}") public User findById(@PathVariable Long id) { return this.restTemplate.getForObject("http://localhost:8000/" + id, User.class); }

本文详细解析了在调用RESTful API时常见的错误,即服务消费者在请求服务提供者时,未在IP端口后正确添加路径分隔符导致的异常。通过对比错误与正确示例代码,清晰地展示了如何避免此类问题。
1063

被折叠的 条评论
为什么被折叠?



