UnknownHostException 错误,构建 java grpc 示例 [英] UnknownHostException error, building java grpc example

查看:33
本文介绍了UnknownHostException 错误,构建 java grpc 示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 这个 grpc 教程 和我什至无法通过第一步.第一步是git clone项目然后运行

I am following this grpc tutorial and I haven't even been able to make it through the first step. The first step is to git clone the project and then run

cd examples
./gradlew installDist

我被这个堆栈跟踪击中了

I am hit with this stack trace

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)

我认为这是一个代理问题,所以我从 这篇文章 并打开文件

I thought that was a proxy issue, so I took some inspiration from this post and opened up the file

gradle/wrapper/gradle-wrapper.properties

并添加行

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

我也用这个替换了 distributionUrl 行

I also replaced distributionUrl line with this

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

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

That is, I switched https --> http.

在这一切之后,我仍然得到相同的堆栈跟踪.

After all of this, I am still getting the same stack trace.

有人有什么建议吗?

我添加了一个

gradle.properties

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

file in the home directory, and added the fields

systemProp.http.proxyHost
systemProd.http.proxyPort

systemProp.https.proxyHost
systemProp.https.proxyPort

但我仍然遇到与以前相同的错误.然而,构建脚本似乎停在这一行

but I still got the same error as before. HOWEVER, the build script appeared to stall on this line

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

大约 10 秒左右,在失败之前.所以……进步了吗?

For about 10 seconds or so, before failing. So... progress?

推荐答案

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

I had the same problem and finally found this solution after 2 hours...

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

Go to the file gradlew.bat in your project and change DEFAULT_JVM_OPTS variable as below:

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.

这篇关于UnknownHostException 错误,构建 java grpc 示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆