我正在尝试使用以下命令在终端中创建一个新的 Maven 项目:
mvn archetype:generate -DgroupId=com.my.domain -DartifactId=myproject -DarchetypeArtifactId=wildfly-javaee7-webapp-archetype -DinteractiveMode=false
所以我正在尝试使用 Wildfly 原型(prototype) 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
下载原型(prototype),这是不正确的,因为原型(prototype)是由 提供的http://mvnrepository.com/artifact/org.wildfly.archetype
。
如何更改来源或如何添加其他来源?还是我错过了一些不同的东西?
最佳答案
您需要定义 archetypeGroupId
,否则,它将默认为 Maven 默认原型(prototype)的 groupId。此外,您需要定义 archetypeVersion
.
在这种情况下,您需要有 archetypeGroupId=org.wildfly.archetype
和 archetypeVersion=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.org
和 mvnrepository.com
都是 Maven Central 并且包含相同的 Artifact 。
关于java - 创建新的 Maven 项目时找不到所需的原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36333952/