我在localhost:8086/addMessage上有一个rest API,当我使用POSTMAN测试它时,它可以工作。但是当我想在客户端集成这个API时,它返回:
java.net.URISyntaxException: Expected scheme-specific part at index 10: localhost:
at java.net.URI$Parser.fail(URI.java:2848) ~[na:1.8.0_171] error:
字符串
这是我调用API的方法:
public void addOrder(Message orders) throws Exception
{ RestTemplate restTemplate = new RestTemplate();
String resp = restTemplate.postForObject(
"localhost:8086/addMessage",
orders,
String.class);
}
型
我该怎么解决呢?
3条答案
按热度按时间3vpjnl9f1#
添加'http'方案到您的网址,
http://localhost:8086/addMessage
zqry0prt2#
如果你使用localhost然后通过这样的url-http://localhost:8080/api/notes定义方案是重要的(http/https)不要使用空间也.对于你的问题答案应该是-http://localhost:8086/addMessage
vnjpjtjt3#
添加**http://或https://**方案的URL已为我工作
字符串
或
型
感谢@stacker和@Shubham