1. 程式人生 > >解決Maven依賴報錯問題

解決Maven依賴報錯問題

問題現象:從svn上籤下原始碼,本地執行打包命令,提示如下錯誤:

[ERROR] Failed to execute goal on project dddwriter: Could not resolve dependencies for project com.xxx.yyy:dddwriter:jar:1.0.0: Failed to collect dependencies at com.xxx.yyy:zzzplugin:jar:1.0.0: Failed to read artifact descriptor for com.xxx.yyy:zzzplugin:jar:1.0.0: Failure to find com.xxx.yyy: aa-bb-zzz:pom:1.0.0 in http://10.10.1.5:8081/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]

分析:開始以為原因是找不到zzzplugin:jar,這個是本地的一個專案模組,可以打包成功,仔細看提示,說的是Failed to collect,並非找不到jar包。最後一個Failure to find ... 點出了根本原因,找不到  aa-bb-zzz構建,而且是線上找不到(當然首先本地沒有才會去線上找),這個構建作用是提供dddwriter和zzzplugin的父pom,打包dddwriter時,因為依賴的zzzplugin沒有在倉庫找到此構建,所以失敗。

總結:在有父pom的情況下,打包上傳子構建會導致引用此構建的專案無法成功打包。

解決辦法:直接打包父構建。

ps: 一開始並不是想直接打包子模組,只是因為前人將子模組的name設定的非常像父模組(應該是手誤),加上在IDEA裡面,父子模組是平級的,所以把它當父模組打包了,後來找出真正的父模組,一次打包成功。