java 执行 Maven archetype generate 命令以创建 Opendaylight 项目结构时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43570594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error executing Maven archetype generate command to create a Opendaylight project structure
提问by Oscar Zhang
When I execute this:
当我执行此操作时:
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
I got the following error:
我收到以下错误:
[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]
And help1 looks like this:
help1 看起来像这样:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
which hasn't been update for a long time.
好久没更新了。
First, I removed backslash and whitespace, obviously it didn't work. I thought it may be the parameter of archetypeCatalog, so I ran this:
首先,我删除了反斜杠和空格,显然它不起作用。我以为可能是archetypeCatalog的参数,所以我运行了这个:
mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeCatalog=remote -DarchetypeVersion=1.1.2-Beryllium-SR2
I got a error like this:
我收到这样的错误:
[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]
The tutorial mentions that OpenDaylight maintains its own repositories outside of Maven Central, which means maven cannot resolve OpenDaylight artifacts by default. So I did as tutorial with following command:
该教程提到 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
I even tried this:
我什至试过这个:
cp -n ~/.m2/settings.xml{,.orig} ; \ wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/stable/beryllium/settings.xml > ~/.m2/settings.xml
The settings.xml files just look the same. I have seen some similar issues these days. As a noob of both maven and opendaylight, I have no idea about what to do next step? I just want to generate an opendaylight arachetype to start a toaster.
settings.xml 文件看起来是一样的。这些天我看到了一些类似的问题。作为 maven 和 opendaylight 的菜鸟,我不知道下一步该做什么?我只想生成一个 opendaylight 原型来启动烤面包机。
Thank you for your help. Here is my maven inforamtion:
谢谢您的帮助。这是我的 Maven 信息:
? ~ 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"
采纳答案by Robert Scholte
With maven-archetype-plugin 3.x it is not possible anymore to specify the repository as commandline argument (for consistency and security reasons).
使用 maven-archetype-plugin 3.x 不再可能将存储库指定为命令行参数(出于一致性和安全性原因)。
So you have 2 options:
所以你有两个选择:
- Follow the new instructions
- Lock the version of the plugin to 2.4
- 遵循新的说明
- 将插件版本锁定为2.4
回答by begginghard
As of Maven Archetype Plugin 3.0.0 the archetype resolution has changed. It is not possible anymore to specify the repository via the commandline, but instead the repositories as already specified for Maven are used. This means that also the mirrors and proxies are respected, as well as the authentication on repositories. 1.You would to delete -DarchetypeCatalog & -DarchetypeRepository 2. In your .m2/setting.xml, add
从 Maven Archetype Plugin 3.0.0 开始,原型分辨率已经改变。不再可能通过命令行指定存储库,而是使用已经为 Maven 指定的存储库。这意味着镜像和代理以及对存储库的身份验证也受到尊重。 1.您将删除 -DarchetypeCatalog & -DarchetypeRepository 2. 在您的 .m2/setting.xml 中,添加
<settings>
<mirrors>
<mirror>
<id>mrm-maven-plugin</id>
<name>Mock Repository Manager</name>
<url>http://www.mycompany.com/maven-reporistory-manager</url>
<mirrorOf>*,!archetype</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>acme</id>
<repositories>
<repository>
<id>archetype</id>
<url>https://www.acme.com/repo</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>acme</activeProfile>
</activeProfiles>
</settings>
回答by Oscar Zhang
Add a repository whose id is archetype like this:
添加一个 id 为原型的存储库,如下所示:
<repository>
<id>archetype</id>
<url>https://repository.domain.com/path/to/repo/</url>
</repository>
In my case,
就我而言,
<repository>
<id>archetype</id>
<url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
</repository>
Basically, I executed without-DarchetypeRepository parameter, but put it in the settings.xml as above. And change -Darchetypecatalog parameter into remote or just set it empty. It works .
基本上,我在没有-DarchetypeRepository 参数的情况下执行,但将其放在settings.xml 中,如上。并将 -Darchetypecatalog 参数更改为 remote 或将其设置为空。有用 。
回答by Learner
Recent Maven version doesn't support commandline definition for archetype. So, In short your default setting file should look like the following (vi ~/.m2/setting.xml),
最近的 Maven 版本不支持原型的命令行定义。因此,简而言之,您的默认设置文件应如下所示 (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>
回答by Ojonugwa Jude Ochalifu
If you are here because you got this error message while creating a Ninja
project, just download the latest version of Maven.(anything > than 2.5.2).
如果您是因为在创建Ninja
项目时收到此错误消息而来到这里,只需下载最新版本的 Maven。(任何大于 2.5.2 的版本)。
This error occurred in Apache Maven versions less than 2.5.3
Apache Maven 低于 2.5.3 版本出现此错误