1. 程式人生 > 其它 >解決:Could not resolve dependencies for project xxx: Could not find artifact xxx

解決:Could not resolve dependencies for project xxx: Could not find artifact xxx

引言

執行A module,找不到B module的依賴報錯。A、B module都在project中。

  • 報錯資訊
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------< com.totainfo.schedulingsystem:aps >------------------
[INFO] Building aps 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.totainfo.schedulingsystem.strategy:aps-strategy-schedule-wip:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.872 s
[INFO] Finished at: 2021-12-30T20:55:47+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project aps: Could not resolve dependencies for project com.totainfo.schedulingsystem:aps:jar:0.0.1-SNAPSHOT: Could not find artifact com.totainfo.schedulingsystem.strategy:aps-strategy-schedule-wip:jar:0.0.1-SNAPSHOT -> [Help 1]
[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/DependencyResolutionException

Process finished with exit code 1

原因分析

我之前通過設定,將程式碼的build工作委託給了maven。

所以我點選執行的時候,idea不會使用自帶的build功能進行build,而是使用maven進行build。

而點開看執行配置會發現,啟動前的行為Build

檢視log可知maven只會build當前module,所以其它module的依賴找不到。

解決方法

修改執行配置,執行前Build Project

點選執行,可以從log中看到maven將其它module也build了,問題解決。