首页 > 解决方案 > 未使用 Maven settings.xml

问题描述

我正在创建一个包含父 pom 的 maven 模块。这个父工件存储在一个 nexus maven 存储库中。我将 nexus 存储库添加到我的 settings.xml 中。现在,如果我正在构建我的子模块,我会遇到错误: Could not find artifact test:my.parent:pom:1.0

似乎settings.xml默认情况下不使用 。如果我添加 <repositories><repository><id>random</id><url>http://test/repository/maven-releases/</url></repository></repositories>到我的孩子的 pom 中一切正常,则使用 settings.xml 并找到父工件。

我是否遗漏了默认情况下将使用 settings.xml 的任何内容,或者这是预期的行为?我不想将这个随机 repo 标签添加到我的每个子 pom 中。

家长会:

  <groupId>test</groupId>
  <artifactId>my.parent</artifactId>
  <version>1.0</version>
  <packaging>pom</packaging>

模块Pom:

  <parent>
    <groupId>test</groupId>
    <artifactId>my.parent</artifactId>
    <version>1.0</version>
  </parent>

  <artifactId>my.module</artifactId>
  <version>1.0</version>
  <packaging>pom</packaging>

设置.xml

<settings>
  <mirrors>
    <mirror>
      <id>Nexus</id>
      <url>http://mynexus:8081/repository/maven-group/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>
<settings

标签: javamavensettingsnexus

解决方案


据我所知,您可以使用 IDE 或命令行调用 maven。

如果您从 IDE 调用,请检查设置是否映射到您的 settings.xml 文件

如果您使用的是命令行,您可以通过 using 进行检查mvn --v,它会显示您的 Maven 主页在哪里。然后你可以在下面检查你的设置文件conf/settings.xml


推荐阅读