gpt4 book ai didi

java - Googleapis.com 未知主机异常

转载 作者:行者123 更新时间:2023-12-03 20:38:56 29 4
gpt4 key购买 nike

以下问题:我试图通过 Google Books API 获取信息,我发现 this Example ,但是如果我执行它,它会出现以下错误。

java.net.UnknownHostException: www.googleapis.com
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:93)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:972)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at de.example.books.Main.queryGoogleBooks(Main.java:44)
at de.example.books.Main.main(Main.java:145)

在主线 44 中:Volumes volumes = volumesList.execute();

我希望你能理解我的问题,我的英语并不完美。 :/

最佳答案

正如我在关于测试的评论中所述,您可以使用 ping 访问服务器 -

ping www.googleapis.com

您需要与您的管理员核实您是否被允许绕过,并且可能要求他们添加一个规则来为 googleapi 提供服务。

也可能是您需要设置代理以允许 java 调用 googleapi - 您可以从浏览器访问 url

关于java - Googleapis.com 未知主机异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33938945/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com