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

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>

 

 

 

 

 

 

相關文章