未知主机异常,但网站可访问



我正在使用IntelliJ IDEA来实现使用REST服务的Spring Guide

https://spring.io/guides/gs/consuming-rest/

当我运行应用程序类时,我收到以下错误

Exception in thread "main" org.springframework.web.client.ResourceAccessException: 
I/O error on GET request for "https://gturnquist-quoters.cfapps.io/api/random": 
gturnquist-quoters.cfapps.io; 
nested exception is 
java.net.UnknownHostException: gturnquist-quoters.cfapps.io

URL本身(https://gturnquist-quoters.cfapps.io/api/random(在浏览器中可以正常打开,我在IntelliJ中的HTTP代理设置可以毫无问题地连接到该站点。 为什么会在这里抛出 UnknownHostException?

嘿,

我知道这有点晚了,但这是我必须做的来解决这个问题。即使您使用系统代理,无论出于何种原因,使用这种类型的 GET 请求也需要您构建一个要在调用中使用的代理,如下所示。

示例图像

最新更新