2015-05-29 94 views
4

我正在尝试构建一个包含在Gradle分发中的示例项目。当我做gradle build我得到这个错误:gradle build failure连接到https://repo1.maven.org拒绝

Could not resolve commons-collections:commons-collections:3.2.1. 
Required by: 
    :application:1.0.2 
> Could not HEAD 'https://repo1.maven.org/maven2/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.pom'. 
    > Connection to https://repo1.maven.org refused 

我背后的代理工作。我试过这里提到的东西: gradle documentation for proxy configuration但我得到了同样的错误。 你能帮忙吗?

回答

8

添加gradle.properties下一个文件与此内容的.gradle文件:

systemProp.http.proxyHost=www.somehost.org 
systemProp.http.proxyPort=8080 
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost 

systemProp.https.proxyHost=www.somehost.org 
systemProp.https.proxyPort=8080 
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost 
+1

您可能需要添加systemProp.http.proxyUser = my_user_name systemProp.http.proxyPassword = my_secret_password ... systemProp .https.proxyUser = my_user_name systemProp.https.proxyPassword = my_secret_password。另外,对于Windows机器,gradle.properties文件位于C:\ Documents and Settings \ myAccount \ .gradle \ gradle.properties中。并检查你有一个“GRADLE_USER_HOME”环境变量指向C:\ Documents and Settings \ myAccount \ .gradle – mycowan

+0

感谢它为我工作:) –