无法访问nexus repo以下载依赖项

时间:2016-02-29 16:32:06

标签: gradle maven-2 nexus

我可以看到该服务已成功托管。

enter image description here

我的gradle脚本看起来像这样

group 'com.tinkering'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'idea'


sourceCompatibility = 1.8

repositories {
    //mavenCentral()
    maven{
        url 'http://linkxserver:8081/nexus/content/repositories/central/'
      //url 'http://localhost:8081/nexus/content/repositories/central/'

    }
}

dependencies {
    compile 'com.google.code.gson:gson:2.3.1'

    testCompile group: 'junit', name: 'junit', version: '4.11'

}

当我尝试运行gradle构建时,我得到了未知的主机异常

$ ./gradlew clean build
:clean UP-TO-DATE
:compileJava

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve com.google.code.gson:gson:2.3.1.
  Required by:
      com.tinkering:gradletinker:1.0-SNAPSHOT
   > Could not resolve com.google.code.gson:gson:2.3.1.
      > Could not get resource 'http://linkxserver:8081/nexus/content/repositories/central/com/google/code/gson/gson/2.3.1/gson-2.3.1.pom'.
         > Could not HEAD 'http://linkxserver:8081/nexus/content/repositories/central/com/google/code/gson/gson/2.3.1/gson-2.3.1.pom'.  Received status code 502 from server: internal error - server connection terminated

我在http://linkxserver:8081/nexus/content/repositories/central/com/google/code/gson/gson/2.3.1/gson-2.3.1.pom做了一个卷曲并让pom回来了。

我已经设置了代理服务器,并且我有以下存储库配置设置:

enter image description here

我在本地机器上执行了完全相同的步骤并且工作正常: - (

更新:“浏览存储”标签显示了pom,但未显示已下载的任何jar文件。

enter image description here

1 个答案:

答案 0 :(得分:0)

您必须在setting.xml中设置代理并添加

<proxy>
    <id> MyId </id>
    <active>true</active>
    <protocol>http</protocol>
    <host>yourAdress</host>
    <port>yourPort</port>
</proxy>

https://stackoverflow.com/a/26293538/7557036

上存在类似问题