【问题标题】:Maven Nexus can't find a dependencyMaven Nexus 找不到依赖项
【发布时间】:2021-07-19 15:15:42
【问题描述】:

我在本地网络上安装了 Nexus OSS 3.29,我可以启动它 (http://somehost:8081/ ) 并浏览它。我将“commons-lang-3.1.jar”上传到“maven-releases”,我可以在那里看到它。我在 Eclipse 中有一个 Maven 项目,我在其中定义了一个依赖项:

<dependency>
  <groupId>commons-lang</groupId>
  <artifactId>commons-lang</artifactId>
  <version>3.1</version>
</dependency>

在我的“settings.xml”中,我定义了存储库:

  <profiles>
    <profile>
      <id>java-net-public</id>
      <repositories>
        <repository>
          <id>java-net-public</id>
          <name>Java Net Public</name>
          <url>http://somehost:8081/maven-releases/</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
          </snapshots>
        </repository>                         
        
      </repositories>
....

</profile>

.....

</profiles>

当我构建我的项目(RunAs->Maven 使用 -e 选项安装)时,我收到一个错误:

Could not find artifact commons-lang:commons-lang:jar:3.1 in java-net-public (http://somehost:8081/maven-releases/)

我觉得我缺少一些配置设置,不确定是什么。我还尝试将存储库定义添加到我的“pom.xml”中,但没有成功。

【问题讨论】:

标签: maven dependencies nexus3


【解决方案1】:

显然,当使用 Nexus 作为存储库时,URL 应该是这样的:

http://somehost:8081/repository/

我将“存储库”添加到 URL 后,Maven 依赖项就得到了解决。

【讨论】:

  • 您所做的是从 Central 手动下载“org.apache.commons:commons-lang3”并将其作为“commons-lang:commons-lang”上传到本地,从而打破两者之间的任何关系.不是很好。这个只有你自己知道。如果有 CWE(漏洞)或版本怎么办?更新,甚至另一个 jar 将其声明为依赖项?在 Nexus 中设置到 Central 的代理并使用真正的 GAV。
猜你喜欢
  • 2014-06-23
  • 2016-10-01
  • 2020-04-18
  • 1970-01-01
  • 1970-01-01
  • 2016-06-12
  • 2014-11-20
  • 2017-09-18
相关资源
最近更新 更多