Maven 未从正确的存储库中提取依赖项

发布于 2025-01-10 17:23:11 字数 2658 浏览 0 评论 0原文

我在 Nexus 存储库管理器中设置了 3 个存储库,

COMPANY_maven-proxy -> proxies https://repo1.maven.org/maven2/
COMPANY_maven-redhat-proxy -> proxies https://maven.repository.redhat.com/ga/
3rd-Party-Tools -> our companies homegrown 3rdParty dependencies 

当我运行 mvn install 命令时,它会从每个存储库中提取我要查找的所有内容(依赖项本身和传递依赖项)。除了一个之外,全部都是!

org.jboss.seam.integration:jboss-seam-int-jbossas:pom:7.0.0.GA 

此依赖项位于 Redhat maven 存储库中:

<dependency>
   <groupId>org.jboss.seam.integration</groupId>
   <artifactId>jboss-seam-int-jbossas</artifactId>
   <version>7.0.0.GA</version>
   <type>pom</type>
</dependency>

无论出于何种原因,此依赖项都是在 COMPANY_maven-proxy 存储库而不是 COMPANY_maven-redhat-proxy 存储库下查找。

这是我的 settings.xml 的内容:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
    <mirrors>
    <mirror>
      <!--This sends everything to COMPANY_maven-proxy that isn't in COMPANY_maven-redhat-proxy -->
      <id>COMPANY_maven-proxy</id>
      <url>http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/</url>
      <mirrorOf>*,!COMPANY_maven-redhat-proxy</mirrorOf>
    </mirror>
    <mirror>
      <!-- This sends everything to COMPANY_maven-redhat-proxy that isn't in COMPANY_maven-proxy -->
      <id>COMPANY_maven-redhat-proxy</id>
      <url>http://FQDN:8081/nexus/repository/COMPANY_maven-redhat-proxy/</url>
      <mirrorOf>*,!COMPANY_maven-proxy</mirrorOf>
    </mirror>
    <mirror>
      <!--This sends everything else to 3rd-Party-Tools -->
      <id>3rd-Party-Tools</id>
      <url>http://FQDN:8081/nexus/repository/3rd-Party-Tools/</url>
      <mirrorOf>!COMPANY_maven-proxy,!COMPANY_maven-redhat-proxy</mirrorOf>
    </mirror>
  </mirrors>
</settings>

这是我收到的错误:

Failed to collect dependencies at org.jboss.seam.integration:jboss-seam-int- 
jbossas:pom:7.0.0.GA: Failed to read artifact descriptor for org.jboss.seam.integration:jboss- 
seam-int-jbossas:pom:7.0.0.GA: Could not find artifact org.jboss.seam.integration:jboss-seam- 
int:pom:7.0.0.GA in COMPANY_maven-proxy (http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/) -> [Help 1]

我已在 标记内尝试了多种组合,但没有任何效果。我什至将这种传递依赖关系放在我的 pom 中的 和/或 下。

任何对此的帮助将不胜感激!

谢谢!

I have 3 repositories setup in our Nexus Repository manager

COMPANY_maven-proxy -> proxies https://repo1.maven.org/maven2/
COMPANY_maven-redhat-proxy -> proxies https://maven.repository.redhat.com/ga/
3rd-Party-Tools -> our companies homegrown 3rdParty dependencies 

When I run the mvn install command it pulls everything I'm looking for from each of these repositories (the dependency itself and the transitive dependencies). All except for one!

org.jboss.seam.integration:jboss-seam-int-jbossas:pom:7.0.0.GA 

This dependency lives in the Redhat maven repository:

<dependency>
   <groupId>org.jboss.seam.integration</groupId>
   <artifactId>jboss-seam-int-jbossas</artifactId>
   <version>7.0.0.GA</version>
   <type>pom</type>
</dependency>

For whatever reason, this one dependency is looking under the COMPANY_maven-proxy repository instead of the COMPANY_maven-redhat-proxy repository.

Here's what I have for my settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
    <mirrors>
    <mirror>
      <!--This sends everything to COMPANY_maven-proxy that isn't in COMPANY_maven-redhat-proxy -->
      <id>COMPANY_maven-proxy</id>
      <url>http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/</url>
      <mirrorOf>*,!COMPANY_maven-redhat-proxy</mirrorOf>
    </mirror>
    <mirror>
      <!-- This sends everything to COMPANY_maven-redhat-proxy that isn't in COMPANY_maven-proxy -->
      <id>COMPANY_maven-redhat-proxy</id>
      <url>http://FQDN:8081/nexus/repository/COMPANY_maven-redhat-proxy/</url>
      <mirrorOf>*,!COMPANY_maven-proxy</mirrorOf>
    </mirror>
    <mirror>
      <!--This sends everything else to 3rd-Party-Tools -->
      <id>3rd-Party-Tools</id>
      <url>http://FQDN:8081/nexus/repository/3rd-Party-Tools/</url>
      <mirrorOf>!COMPANY_maven-proxy,!COMPANY_maven-redhat-proxy</mirrorOf>
    </mirror>
  </mirrors>
</settings>

Here's the error I get:

Failed to collect dependencies at org.jboss.seam.integration:jboss-seam-int- 
jbossas:pom:7.0.0.GA: Failed to read artifact descriptor for org.jboss.seam.integration:jboss- 
seam-int-jbossas:pom:7.0.0.GA: Could not find artifact org.jboss.seam.integration:jboss-seam- 
int:pom:7.0.0.GA in COMPANY_maven-proxy (http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/) -> [Help 1]

I've tried multiple combination's within the <mirrorOf> tag but nothing has worked. I've even put this transitive depency in my pom under <dependencies> and/or <dependencyManagement>.

Any help on this would be appreciated!

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两相知 2025-01-17 17:23:11

这些镜像适用于已声明的现有存储库。在您的 settings.xml 中,您没有列出存储库,而是列出了默认的 Maven Central。因此,仅定义 Maven Central 的镜像并重定向到公司的 Nexus 存储库是有意义的。使用一种罕见的技巧,可以为任何外部存储库注册一个镜像,例如:

    <mirror>
      <id>public</id>
      <mirrorOf>central</mirrorOf>
      <name>Let the default Maven Central repository is resolved in the local Nexus' public repository</name>
      <url>http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/</url>
    </mirror>

示例中的任何镜像都应该在 pom.xml 中注册为存储库。

编辑:

  • 删除了第二个(“其他”)镜像,因为该示例是根据存储库管理器直接在本地主机上运行的情况改编的。

The mirrors are for already existing repositories declared. In your settings.xml you do not have repositories listed, but the default Maven Central. Thus it makes sense to define just a mirror of Maven Central, redirecting to the company's Nexus repo. with a rare trick, one could register a mirror for any external repos, for example:

    <mirror>
      <id>public</id>
      <mirrorOf>central</mirrorOf>
      <name>Let the default Maven Central repository is resolved in the local Nexus' public repository</name>
      <url>http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/</url>
    </mirror>

Any mirror from your example should be registered in the pom.xml as repositories.

Edited:

  • removed the second ("other") mirror, as the example was adapted from a case where the repository manager to direct to runs at localhost.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文