Maven 編譯父子項目找不到父pom超級巨坑


異常信息:

[FATAL] Non-resolvable parent POM for xxxxx: Failure to transfer xxxxxx from xxxxxxxxxxxx was cached in the local repository, resolution will not be reattempted until the update interval of nexus-snapshots has elapsed or updates are forced. Original error: Could not transfer artifact xxxxxxxxxx from/to nexus-snapshots (xxxxxxxxx): Transfer failed for xxxxxx 400 Repository version policy: SNAPSHOT does not allow version: 0.20.3 and 'parent.relativePath' points at wrong local POM @ line 5, column 13

網上看很多都把矛頭指向parent.relativePath,這里異常提示的也是parent.relativePath問題,然后就會陷入懷疑人生的搜索和parent.relativePath相關的詞條。

當然,首先檢查的是parent.relativePath是否真的配錯,如果parent.relativePath沒有配錯,並且gourpId,artifactId,version都沒問題,同時,編譯還會去遠程倉庫拉取父pom,筆者遇到的問題出現在一次修改groupId的過程中,所以遠程倉庫是找不到父pom的,這個時候就會懷疑人生了,按道理是優先從本地文件系統查找父pom,然后是local repository,最后是remote repository。這個時候自然想到的就是install父pom,但是,install的時候依然報了同樣的錯誤,試了各種方法依舊不靈,最后偶然的發現報錯的子pom數量並非等於所有的子pom數,於是,對比所有子pom的parent節點發現,version存在差異,沒問題的version通過${version}引用的父pom中的properties,有問題的version直接寫死的具體版本號,兩種寫法的具體version值是一致的,通過反復試驗發現,結論是:子pom里面parent.version必須與父pom里面的version寫法一致,筆者項目內的父pom version引用的${version},所有相同寫法的子pom編譯沒問題。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM