maven项目构建报错:Could not find artifact com.xxx.cloud:xxx-cloud:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM
maven多模块项目打包的时候报错如下:
[ERROR] [ERROR] Some problems were encountered while processing the POMs: [FATAL] Non-resolvable parent POM for com.xxx.cloud:common:1.0-SNAPSHOT: Could not find artifact com.xxx.cloud:xxx-cloud:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 5, column 13 @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project com.xxx.cloud:common:1.0-SNAPSHOT (xxx\common\common\pom.xml) has 1 error [ERROR] Non-resolvable parent POM for com.xxx.cloud:common:1.0-SNAPSHOT: Could not find artifact com.xxx.cloud:xxx-cloud:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 5, column 13 -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
找了很久原因,终于找到,这个是maven多模块项目,之前的做法是将多个模块放父级pom.xml同级下,所以没问题,现在我将模块按功能分成了三大类,放三个目录下,因此pom.xml的模块引用路径需要改一下:
1.父pom.xml引用子级模块时需要增加相对路径:
2.子模块引用parent时,需要增加以下代码(我就是少了这行所以报错,具体路径得看你子模块的pom.xml和父pom.xml差多少层目录,我的是差两层):
<relativePath>../../pom.xml</relativePath>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了