openfegin Illegal character in path at index
程序员文章站
2022-03-10 18:14:56
...
使用openfeign遇到一个简单错误:
Caused by: java.net.URISyntaxException: Illegal character in path at index 32: http://test-service/v1/tests/py/{pid}
at java.net.URI$Parser.fail(URI.java:2848) ~[?:1.8.0_181]
at java.net.URI$Parser.checkChars(URI.java:3021) ~[?:1.8.0_181]
at java.net.URI$Parser.parseHierarchical(URI.java:3105) ~[?:1.8.0_181]
at java.net.URI$Parser.parse(URI.java:3053) ~[?:1.8.0_181]
at java.net.URI.<init>(URI.java:588) ~[?:1.8.0_181]
at java.net.URI.create(URI.java:850) ~[?:1.8.0_181]
at org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient.execute(LoadBalancerFeignClient.java:56) ~[spring-cloud-openfeign-core-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.cloud.sleuth.instrument.web.client.feign.TraceLoadBalancerFeignClient.execute(TraceLoadBalancerFeignClient.java:67) ~[spring-cloud-sleuth-core-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:98) ~[feign-core-9.7.0.jar:?]
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:77) ~[feign-core-9.7.0.jar:?]
从错误上看,这只是一个非法的url造成的,但是实际检查发现,根本原因不是这个,我有一个commonservice需要调用testservice,调用代码:
@GetMapping(value= "v1/tests/py/{pid}")
Message<List<PPyVO>> getPPy(@PathVariable("pid") Long pid);
发现调用这个接口的时候,传递的参数是null,原来我认为就算是null也应该把{pid}给替换掉,但是实际上并不会,所以产生了这个问题。
下一篇: Nginx 配置指令的执行顺序(八)
推荐阅读
-
java.lang.IllegalArgumentException: Illegal character in query at index 141:
-
java.lang.IllegalArgumentException: Illegal character in query at index 141:
-
微信公众号:遇到Illegal character in query at index XXX
-
ERROR: Illegal character in opaque part at index 2: F:\Android\.android\debug.keystore
-
openfegin Illegal character in path at index