为什么maven没有从指定的存储库

时间:2017-08-04 02:55:38

标签: maven repository maven-archetype artifact

我在Windows 10上运行Maven 3.5。在.m2 / settings.xml

中设置两个存储库
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>maven-release</name>
      <url>https://artifacts.repo.openearth.community/artifactory/distarch-maven-staging</url>
    </repository>
    <repository>
      <snapshots />
      <id>snapshots</id>
      <name>maven-snapshots</name>
      <url>https://artifacts.repo.openearth.community/artifactory/distarch-maven-snapshots</url>
    </repository>
  </repositories>

现在我需要从maven-release repo中发布的自定义快速入门原型创建项目。

mvn archetype:generate -DarchetypeGroupId=com.lgc.dist -DarchetypeArtifactId=com.lgc.dist.core.msp.quickstart -DarchetypeVersion=0.1 -DinteractiveMode=false -DgroupId=com.foo -DartifactId=com.foo.example.firstservice -Dversion=1.0-SNAPSHOT -DserviceName=FirstService -Dpackage=com.foo.example.firstservice

com.lgc.dist.core.msp.quickstart提供了快速入门工件https://artifacts.repo.openearth.community/artifactory/distarch-maven-staging/com/lgc/dist/com.lgc.dist.core.base.pom/0.1/com.lgc.dist.core.base.pom-0.1.pom。 jar也一样。

然而,mvn命令的输出显示它正在尝试从apache.org maven存储库下载,该存储库未在settings.xml文件中的任何位置定义

[INFO] Generating project in Batch mode
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repsoitory with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
Downloading: https://repo.maven.apache.org/maven2/com/lgc/dist/com.lgc.dist.core.msp.quickstart/0.1/com.lgc.dist.core.msp.quickstart-0.1.pom
[WARNING] The POM for com.lgc.dist:com.lgc.dist.core.msp.quickstart:jar:0.1 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/com/lgc/dist/com.lgc.dist.core.msp.quickstart/0.1/com.lgc.dist.core.msp.quickstart-0.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.488 s
[INFO] Finished at: 2017-08-03T21:46:38-05:00
[INFO] Final Memory: 15M/170M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: The desired archetype does not exist (com.lgc.dist:com.lgc.dist.core.msp.quickstart:0.1) -> [Help 1]

我运行mvn -X来检查它正在使用哪个设置文件,它显示它是.m2 / settings.xml。为什么不起作用? Windows 10有什么特殊的设置吗?相同的命令适用于具有相同设置的Linux VM。

2 个答案:

答案 0 :(得分:0)

由于某些原因,在存储库中找不到原型,或者无法联系存储库,然后它说:

Archetype not found in any catalog. Falling back to central repository.

如果将存储库设置为镜像,则可以避免此行为。

答案 1 :(得分:-1)

由于安全原因,在maven 3.x版本中,maven-archetype-plugin 3.x不可能从命令行参数到特定存储库。你可以参考这个链接http://maven.apache.org/archetype/maven-archetype-plugin/archetype-repository.html。你可以使用下面的版本