maven项目构建报错:Could not find artifact com.xxx.cloud:xxx-cloud:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM

时间:2023-02-16 20:06:37

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的模块引用路径需要改一下:

maven项目构建报错:Could not find artifact com.xxx.cloud:xxx-cloud:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM

 

 

1.父pom.xml引用子级模块时需要增加相对路径:

 

 maven项目构建报错:Could not find artifact com.xxx.cloud:xxx-cloud:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM

 

2.子模块引用parent时,需要增加以下代码(我就是少了这行所以报错,具体路径得看你子模块的pom.xml和父pom.xml差多少层目录,我的是差两层):

<relativePath>../../pom.xml</relativePath>

maven项目构建报错:Could not find artifact com.xxx.cloud:xxx-cloud:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM