Java 创建新的maven项目时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23217454/
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 when creating a new maven project
提问by Kleber Mota
When I try create a new maven project (with several archetypes, not only the one below), I am facing this error:
当我尝试创建一个新的 maven 项目(有几个原型,而不仅仅是下面的一个)时,我遇到了这个错误:
Unable to create project from archetype [org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE]
Unable to add module to the current project as it is not of packaging type 'pom'
Anyone know why this is happening, and how to solve it?
任何人都知道为什么会发生这种情况,以及如何解决它?
采纳答案by pdem
It seems that your directory is not empty. this command line works for me: (in an empty directory)
看来你的目录不是空的。这个命令行对我有用:(在一个空目录中)
mvn archetype:generate -DgroupId=fr.myGroupId -DartifactId=MyApplication -Dpackagename=fr.myGroupId -DarchetypeArtifactId=maven-archetype-quickstart
the result is:
结果是:
[INFO] Using property: groupId = fr.myGroupId
[INFO] Using property: artifactId = MyApplication
Define value for property 'version': 1.0-SNAPSHOT: :
[INFO] Using property: package = fr.myGroupId
Confirm properties configuration:
groupId: fr.myGroupId
artifactId: MyApplication2
version: 1.0-SNAPSHOT
package: fr.myGroupId
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: fr.myGroupId
[INFO] Parameter: packageName, Value: fr.myGroupId
[INFO] Parameter: package, Value: fr.myGroupId
[INFO] Parameter: artifactId, Value: MyApplication2
[INFO] Parameter: basedir, Value: /home/ABC-OBJECTIF/philippe.demanget/workspace/pdemanget/tmp/mvn
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: /home/ABC-OBJECTIF/philippe.demanget/workspace/pdemanget/tmp/mvn/MyApplication2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.764s
[INFO] Finished at: Tue Apr 22 13:35:17 CEST 2014
[INFO] Final Memory: 14M/216M
[INFO] ------------------------------------------------------------------------
I can reproduce your error by doing this command line inside the newly created directory:
我可以通过在新创建的目录中执行此命令行来重现您的错误:
cd MyApplication
mvn archetype:create -DgroupId=fr.myGroupId -DartifactId=MyApplication -Dpackagename=fr.myGroupId -DarchetypeArtifactId=maven-archetype-quickstart
[...] [INFO] BUILD FAILURE
回答by Florent Barreau
I got the same issue, solved by manually removing a unused pom.xmlfile at the root of workspace directory
我遇到了同样的问题,通过手动删除工作区目录根目录下未使用的pom.xml文件解决了
回答by Prasanna Muppidi
You have to remove the already existing pom.xml or if you need it to execute the maven command, try adding <packaging>pom</packaging>
to your pom.
您必须删除已经存在的 pom.xml,或者如果您需要它来执行 maven 命令,请尝试添加<packaging>pom</packaging>
到您的pom.xml 中。
Since if you have an already existing in the current directory, it should match with the package structure. It is always to good to start with no pom file in the parent directory.
因为如果当前目录中已经存在一个,它应该与包结构匹配。从父目录中没有 pom 文件开始总是好的。
This should work.
这应该有效。
回答by Jonathan
I was having the same problem using Windows PowerShell in a newly created directory with nothing in it. I tried the command using the regular Windows Command Prompt, and it worked fine.
我在一个新创建的目录中使用 Windows PowerShell 时遇到了同样的问题,其中没有任何内容。我使用常规的 Windows 命令提示符尝试了该命令,它运行良好。