在eclipse中创建maven工程报错

本文介绍在使用Maven创建工程时遇到“Unabletoaddmoduletothecurrentprojectasitisnotofpackagingtype'pom'”错误的原因及解决办法。问题源于工作空间根目录存在pom.xml文件,删除该文件即可正常创建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

【报错,死活不能创建工程】Unable to add module to the current project as it is not of packaging type 'pom'

【原因】workspace的根目录下  有一个  pom.xml  。  之前备份的。。


【解决问题的来源】执行 maven 命令 报错Unable to add module to the current project as it is not of packaging type 'pom' - yang_734664103的专栏 - 优快云博客
http://blog.youkuaiyun.com/yang_734664103/article/details/15783745


-------------------------------------原帖内容---------------------------------------------------------------------

今天学习在本地搭建Maven工程时,执行了mvn archetype:generate 命令,报错。

Unable to create project from archetype [org.apache.maven.archetypes:maven-archetype-quickstart:1.1] 
Unable to add module to the current project as it is not of packaging type 'pom'

上网搜资料发现一个帖子,问题解决:

原文如下:

一开始以为是IDE出错了,很是着急,后来回想出错之前的操作。就在这之前,我备份了一个pom文件,然后直接移到了workspace的根目录下,心想是不是这个问题呢?带着疑问,我把这个pom.xml删掉了,然后再创建maven工程,果然不出所料,不再报错了。

为了确保是这个原因,后来google了一下,在国外一个论坛中碰到类似的问题,有个网友的回答摘抄如下:

Are you running the command from a directory that has an existing pom.xml file in it? I think that may be confusing Maven, as it thinks you're trying to add your new project as a sub-module of the project in the working directory.

原来是因为我在Workspace下放了个POM文件,造成了M2eclipse插件的误解,删掉就OK了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值