执行Maven archetype generate命令以创建Opendaylight项目结构时出错

时间:2017-04-23 11:31:04

标签: java maven opendaylight

执行此操作时:

 mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype \
-DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ \
-DarchetypeCatalog=http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/archetype-catalog.xml

我收到以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: archetypeCatalog 'http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/archetype-catalog.xml' is not supported anymore. Please read the plugin documentation for details. -> [Help 1]

help1看起来像这样:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

已经很长时间没有更新。

首先,我删除了反斜杠和空格,显然它没有用。 我认为它可能是archetypeCatalog的参数,所以我运行了这个:

mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeCatalog=remote -DarchetypeVersion=1.1.2-Beryllium-SR2

我收到了这样的错误:

[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 (org.opendaylight.controller:opendaylight-startup-archetype:1.1.2-Beryllium-SR2) -> [Help 1]

该教程提到OpenDaylight在Maven Central之外维护自己的存储库,这意味着默认情况下maven无法解析OpenDaylight工件。 所以我用以下命令作为教程:

cp -n ~/.m2/settings.xml{,.orig} ; \ wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml

我甚至试过这个:

cp -n ~/.m2/settings.xml{,.orig} ; \ wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/stable/beryllium/settings.xml > ~/.m2/settings.xml

settings.xml文件看起来一样。 这些天我见过一些类似的问题。作为maven和opendaylight的菜鸟,我不知道下一步该做什么?我只想生成一个opendaylight arachetype来启动烤面包机。

感谢您的帮助。 这是我的maven inforamtion:

 ➜  ~ mvn -v
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"

5 个答案:

答案 0 :(得分:5)

使用maven-archetype-plugin 3.x,不可能将存储库指定为命令行参数(出于一致性和安全性原因)。

所以你有两个选择:

答案 1 :(得分:1)

从Maven Archetype Plugin 3.0.0开始,原型分辨率发生了变化。不再可以通过命令行指定存储库,而是使用已经为Maven指定的存储库。这意味着镜像和代理也受到尊重,以及对存储库的身份验证。 你要删除-DarchetypeCatalog& -DarchetypeRepository 2.在.m2 / setting.xml中,添加

writeLines(as.html(myflex), "MyFlexTable.html")
  1. 查看http://maven.apache.org/archetype/maven-archetype-plugin/archetype-repository.html

答案 2 :(得分:0)

添加id为原型的存储库,如下所示:

  <repository>
    <id>archetype</id>
    <url>https://repository.domain.com/path/to/repo/</url>
  </repository>

就我而言,

  <repository>
     <id>archetype</id>
     <url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
  </repository>

基本上,我执行了without-DarchetypeRepository参数,但是将它放在如上所述的settings.xml中。并将-Darchetypecatalog参数更改为remote或将其设置为空。它有效。

答案 3 :(得分:0)

最近的Maven版本不支持archetype的命令行定义。因此,简而言之,您的默认设置文件应如下所示(vi~ / .m2 / setting.xml),

<?xml version="1.0" encoding="UTF-8"?>
<!-- vi: set et smarttab sw=2 tabstop=2: -->
<!--
 Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.

 This program and the accompanying materials are made available under the
 terms of the Eclipse Public License v1.0 which accompanies this distribution,
 and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
    <profile>
      <id>opendaylight-release</id>
      <repositories>
        <repository>
          <id>opendaylight-mirror</id>
          <name>opendaylight-mirror</name>
          <url>https://nexus.opendaylight.org/content/repositories/public/</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>opendaylight-mirror</id>
          <name>opendaylight-mirror</name>
          <url>https://nexus.opendaylight.org/content/repositories/public/</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>

    <profile>
      <id>opendaylight-snapshots</id>
      <repositories>
        <repository>
          <id>opendaylight-snapshot</id>
          <name>opendaylight-snapshot</name>
          <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
<repository>
     <id>archetype</id>
     <url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
  </repository>

    </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>opendaylight-snapshot</id>
          <name>opendaylight-snapshot</name>
          <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
  </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>opendaylight-release</activeProfile>
    <activeProfile>opendaylight-snapshots</activeProfile>
  </activeProfiles>
</settings>

答案 4 :(得分:0)

如果您在这里是因为您在创建Ninja项目时收到此错误消息,请下载最新版本的Maven。(任何&gt;而不是2.5.2)。

Apache Maven版本低于2.5.3时发生此错误