简体   繁体   English

未使用 Maven settings.xml

[英]Maven settings.xml not used

I am creating a maven module including a parent pom.我正在创建一个包含父 pom 的 Maven 模块。 This parent artifact is stored in a nexus maven repository.此父工件存储在 nexus maven 存储库中。 I added the nexus repository to my settings.xml.我将 nexus 存储库添加到我的 settings.xml 中。 Now if I am building my child module I am getting and error: Could not find artifact test:my.parent:pom:1.0现在,如果我正在构建我的子模块,则会出现错误: Could not find artifact test:my.parent:pom:1.0

It seems that the settings.xml is not used per default.似乎默认情况下不使用settings.xml If I add <repositories><repository><id>random</id><url>http://test/repository/maven-releases/</url></repository></repositories> to my childs pom everything works fine, the settings.xml is used and the parent artifact is found.如果我将<repositories><repository><id>random</id><url>http://test/repository/maven-releases/</url></repository></repositories>到我的孩子的 pom 中,一切正常很好,使用 settings.xml 并找到父工件。

Am I missing anything that the settings.xml will be used per default or is this the expected behaviour?我是否错过了默认情况下将使用 settings.xml 的任何内容,或者这是预期的行为? I do not want to add this random repo tag to every of my child poms.我不想将这个随机 repo 标签添加到我的每个子 poms 中。

Parent Pom:父 Pom:

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

Modul Pom:模块化 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>

settings.xml设置.xml

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

As I know you can call maven by using IDE or command line.据我所知,您可以使用 IDE 或命令行调用 maven。

If you are calling from IDE, check the settings if it is mapping to your settings.xml file如果您从 IDE 调用,请检查设置是否映射到您的 settings.xml 文件

If you are using command line, you can check by using mvn --v and it shows you where your maven home is.如果您使用命令行,则可以使用mvn --v进行检查,它会显示您的 Maven 家在哪里。 Then you can check your settings file under conf/settings.xml然后你可以在conf/settings.xml下检查你的设置文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM