Request URI does not contain a valid hostname:http://HELLO_SERVICE/hello

最近在学习spring cloud,在使用注册中心的服务命方式调用接口的过程中,遇到报错:

2018-06-20 15:41:15.388 ERROR 7548 --- [nio-9000-exec-6] 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.IllegalStateException: Request URI does not contain a valid hostname: http://HELLO_SERVICE/hello] with root cause

java.lang.IllegalStateException: Request URI does not contain a valid hostname:http://HELLO_SERVICE/hello at org.springframework.util.Assert.state(Assert.java:73) ~[spring-core-5.1.0.BUILD-SNAPSHOT.jar!/:5.1.0.BUILD-SNAPSHOT]

问题原因:

    在注册服务的时候,properties文件中的服务名(spring.application.name)带上了下划线(如:HELLO_SERVICE)

解决办法:

    将下划线换成横杠即可。

猜你喜欢

转载自blog.csdn.net/u010448530/article/details/80747711