【问题标题】:Unable to access nexus repo to download the dependencies无法访问 nexus 存储库以下载依赖项
【发布时间】:2016-06-12 19:00:26
【问题描述】:

可以看到服务托管成功了。

我的 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 拿回来了。

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

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

更新:“浏览存储”选项卡显示了 pom,但不显示下载的任何 jar 文件。

【问题讨论】:

  • 将该网址放入浏览器,看看是否可以下载 pom 文件。
  • Curl'd 并得到了 pom 作为响应。我已经用另一个快照更新了这个问题。
  • 我会检查服务器的配置并访问原因 Received status code 502 from server: internal error 这看起来很奇怪......

标签: gradle maven-2 nexus


【解决方案1】:

您必须在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也有类似问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 2021-12-31
    • 1970-01-01
    • 1970-01-01
    • 2020-03-28
    • 2016-04-13
    • 2017-07-20
    相关资源
    最近更新 更多