gpt4 book ai didi

java - UnknownHostException错误,构建java grpc示例

转载 作者:行者123 更新时间:2023-11-29 04:39:23 25 4
gpt4 key购买 nike

我正在关注 this grpc tutorial而且我什至连第一步都做不到。第一步git clone项目,然后运行

cd examples
./gradlew installDist

我被这个堆栈跟踪击中了

Downloading https://services.gradle.org/distributions/gradle-2.13-bin.zip

Exception in thread "main" java.net.UnknownHostException: services.gradle.org
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
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.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
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.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install$1.call(Install.java:61)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

我认为这是一个代理问题,所以我从 this post 中得到了一些启发。并打开文件

gradle/wrapper/gradle-wrapper.properties

并添加了行

systemProp.http.proxyHost=<my proxy>
systemProp.http.proxyPort=<my port>

我还用这个替换了 distributionUrl 行

distributionUrl=http\://services.gradle.org/distributions/gradle-2.13-bin.zip 

也就是我切换了https --> http。

所有这一切之后,我仍然得到相同的堆栈跟踪。

有人有什么建议吗?

编辑:我添加了一个

gradle.properties

主目录下的文件,并添加字段

systemProp.http.proxyHost
systemProd.http.proxyPort

systemProp.https.proxyHost
systemProp.https.proxyPort

但我仍然得到和以前一样的错误。然而,构建脚本似乎停滞在这一行

Downloading https://services.gradle.org/distributions/gradle-2.13-bin.zip

大约 10 秒左右,然后失败。那么……有进展吗?

最佳答案

我遇到了同样的问题,2小时后终于找到了这个解决方案...

转到项目中的文件 gradlew.bat 并更改 DEFAULT_JVM_OPTS 变量,如下所示:

set DEFAULT_JVM_OPTS=-Dhttp.proxyHost=YOUR_HOST -Dhttp.proxyPort=PORT -Dhttp.proxyUser=USERNAME -Dhttp.proxyPassword=PASSWORD -Dhttps.proxyHost=YOUR_HOST -Dhttps.proxyPort=PORT -Dhttps.proxyUser=USERNAME -Dhttps.proxyPassword=PASSWORD

然后运行 ​​gradlew clean build

关于java - UnknownHostException错误,构建java grpc示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39881448/

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