Eclipse新建maven project报错‘unable to add module to the current project as it is not of packaging...’

本文解决在Eclipse中创建Maven项目时遇到的“无法将模块添加到当前项目,因为其打包类型不是‘pom’”的问题。通过删除工作空间中的冲突pom.xml或修改其package属性为pom,即可避免此错误。

Eclipse新建maven project报错

在搭建multi-module project,如下,快速新建一个maven project时:
在这里插入图片描述
完整地码进artifactId and groupId,点击finish时,报如下错误:(第一次搭建时,会看到进度条eclipse有去下载maven-archetype.jar。
对于没有联网不能下载的,可以配置镜像,在私服nexus上下载(这个需要知道镜像url配置到conf/setting.xml文件中),
或者在maven官网(http://maven.apache.org/archetype/maven-archetype-plugin/specification/archetype-catalog.html)上下载到本地仓库中,
或者在install窗口让eclipse给你重新下载(http://repo.maven.apache.org/maven2/archetype-catalog.xml)不过这种方法,我总是报no software set in the site.没有成功。)
说回到重点,我的问题不是依赖Jar找不到,而是在我的workspace目录下存在pom.xml,而且该pom.xml中的package定义的不是pom,eclipse会误认为我所要建的项目是要包含在这个pom.xml中,所以导致错误“unable to add module to the current project as it is not of packaging type ‘pom’.”.
在这里插入图片描述

删掉该pom.xml或重新定义该pom.xml中的package成pom,问题就可以解决了。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值