Gradle构建失败[无法解析配置的所有依赖项':compile'.]

Pra*_*mar 11 java eclipse build.gradle

我正在尝试这么多天来解决这个例外,跟着很多博客并找不到解决方案.当我通过给出jettyRun作为命令来运行bundle.gradle时在此输入图像描述

I am getting an exception 



    **FAILURE: Build failed with an exception.

        * What went wrong:
        Could not resolve all dependencies for configuration ':compile'.
        > Could not resolve javax.servlet:servlet-api:2.5.
          Required by:
              :1-SimpleServlet:unspecified
           > Could not GET 'http://repo1.maven.org/maven2/javax/servlet/servlet-api/2.5/servlet-api-2.5.pom'.
              > Connection to http://repo1.maven.org refused
        > Could not resolve org.apache.commons:commons-io:1.3.2.
          Required by:
              :1-SimpleServlet:unspecified
           > Could not GET 'http://repo1.maven.org/maven2/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.pom'.
              > Connection to http://repo1.maven.org refused**
Run Code Online (Sandbox Code Playgroud)

Aar*_*lla 14

真正的错误是这样的:

Connection to http://repo1.maven.org refused
Run Code Online (Sandbox Code Playgroud)

Gradle需要下载错误消息中列出的依赖项才能编译项目.

您可能在防火墙后面或您的Internet连接无法正常工作.您需要确保Gradle可以访问http://repo1.maven.org.

注意:可以使用浏览器访问Maven Central(http://repo1.maven.org).如果您看到消息"浏览此目录已被禁用",则表示您的浏览器可以连接到服务器(错误是我的Maven Central的特殊消息,而不是标准的HTTP错误消息).

如果您看到此但Maven或Gradle失败,则需要检查浏览器的/ OS的代理设置并相应地配置您的工具.

有关:


pho*_*nix 6

使用--refresh-dependencies切换gradle,帮助我解决了这个问题.