【问题标题】:Cant find desired archetype when creating new Maven project创建新的 Maven 项目时找不到所需的原型
【发布时间】:2016-07-19 22:32:43
【问题描述】:

我正在尝试使用以下命令在终端中创建一个新的 Maven 项目:

mvn archetype:generate -DgroupId=com.my.domain -DartifactId=myproject -DarchetypeArtifactId=wildfly-javaee7-webapp-archetype -DinteractiveMode=false

所以我尝试使用 Wildfly 原型 wildfly-javaee7-webapp-archetype

我收到以下错误...

[INFO] Generating project in Batch mode
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/wildfly-javaee7-webapp-archetype/1.0/wildfly-javaee7-webapp-archetype-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.860 s
[INFO] Finished at: 2016-03-31T14:35:27+02:00
[INFO] Final Memory: 16M/188M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.apache.maven.archetypes:wildfly-javaee7-webapp-archetype:1.0) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

...这意味着 Maven 正在尝试在 https://repo.maven.apache.org 下载原型,这是不正确的,因为原型是由 http://mvnrepository.com/artifact/org.wildfly.archetype 提供的。

如何更改来源或如何添加其他来源?还是我错过了什么不同的东西?

【问题讨论】:

  • 你的 pom 包含哪些存储库?

标签: java maven jboss wildfly maven-archetype


【解决方案1】:

您需要定义archetypeGroupId,否则,它将默认为 Maven 默认原型的 groupId。另外,您需要定义archetypeVersion

在这种情况下,您需要拥有archetypeGroupId=org.wildfly.archetypearchetypeVersion=8.2.0.Final (for example)。

因此,您应该:

mvn archetype:generate -DgroupId=com.my.domain -DartifactId=myproject -DarchetypeGroupId=org.wildfly.archetype -DarchetypeArtifactId=wildfly-javaee7-webapp-archetype -DarchetypeVersion=8.2.0.Final -DinteractiveMode=false

附带说明,repo.maven.apache.orgmvnrepository.com 都是 Maven Central,包含相同的工件。

【讨论】:

  • 解决了我的问题!非常感谢! :)
【解决方案2】:

如果其他人在接受接受的答案后遇到问题,请尝试将版本降低到-DarchetypeVersion=8.1.0.Final

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-28
    • 2015-06-05
    • 1970-01-01
    • 2019-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多