创建新的 maven 项目时出错

2022-09-02 22:56:18

当我尝试创建一个新的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'

有谁知道为什么会发生这种情况,以及如何解决它?


答案 1

您的目录似乎不是空的。此命令行适用于我:(在空目录中)

mvn archetype:generate -DgroupId=fr.myGroupId -DartifactId=MyApplication -Dpackagename=fr.myGroupId -DarchetypeArtifactId=maven-archetype-quickstart

结果是:

[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] ------------------------------------------------------------------------

我可以通过在新创建的目录中执行此命令行来重现您的错误:

cd MyApplication
mvn archetype:create -DgroupId=fr.myGroupId -DartifactId=MyApplication -Dpackagename=fr.myGroupId -DarchetypeArtifactId=maven-archetype-quickstart
[...] [INFO] BUILD FAILURE

答案 2

我得到了同样的问题,通过手动删除工作区目录根部未使用的pom.xml文件来解决


推荐