Java 无法创建新的 Maven hello-world 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29147329/
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
Unable to create a new maven hello-world project
提问by London guy
I am looking at few maven tutorial videos and then I ran into this command after installing maven:
我正在看一些 maven 教程视频,然后在安装 maven 后遇到了这个命令:
mvn archetype:create -DgroupId=com.di.maven -DartifactId=hello-world
The build fails and throws the following error:
构建失败并抛出以下错误:
Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.3:create
(default-cli) on project standalone-pom: Unable to parse configuration of mojo
org.apache.maven.plugins:maven-archetype-plugin:2.3:create for parameter #: Abstract
class or interface 'org.apache.maven.artifact.repository.ArtifactRepository' cannot be
instantiated -> [Help 1]
What is the reason and how can I fix it? I am running as an user in Ubuntu.
是什么原因,我该如何解决?我在 Ubuntu 中以用户身份运行。
采纳答案by Ahmet Karakaya
change create
to generate
更改create
为generate
mvn archetype:generate -DgroupId=com.di.maven -DartifactId=hello-world -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
回答by Suresh
mvn archetype:create
is deprecated in Maven 3.0.5 and beyond, as mentioned in the documentation
mvn archetype:create
如文档中所述,在 Maven 3.0.5 及更高版本中已弃用
Use mvn archetype:generate
instead:
使用mvn archetype:generate
来代替:
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-archetype
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-archetype
This is an interactive command and will ask for values like groupId
, artifactId
, version
, etc. You can also specify these values in the command and choose the non-interactive mode.
这是一个交互式命令,会询问诸如groupId
、artifactId
、等值version
。您还可以在命令中指定这些值并选择非交互式模式。
回答by Sidhant101
Add
添加
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
to your pom file in
到你的 pom 文件
{user.home}/.m2/repository/org/apache/maven/plugins/maven-archetype-plugin/2.3
回答by user5458751
mvn archetype:generate
-DgroupId=com.biswajit.maven
-DartifactId=com.biswajit.maven
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
Create does not work in maven 3.0.X or beyond. So use generate instead of create
Create 在 maven 3.0.X 或更高版本中不起作用。所以使用 generate 而不是 create