解决:Could not resolve dependencies for project xxx: Could not find artifact xxx
引言
运行A module,找不到B module的依赖报错。A、B module都在project中。
![](https://img2020.cnblogs.com/blog/1555060/202112/1555060-20211230210727154-1602892525.png)
![](https://img2020.cnblogs.com/blog/1555060/202112/1555060-20211230210719466-730449099.png)
- 报错信息
[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。
![](https://img2020.cnblogs.com/blog/1555060/202112/1555060-20211230210732803-1849243413.png)
所以我点击运行的时候,idea不会使用自带的build功能进行build,而是使用maven进行build。
![](https://img2020.cnblogs.com/blog/1555060/202112/1555060-20211230210739127-506966725.png)
而点开看运行配置会发现,启动前的行为Build
。
![](https://img2020.cnblogs.com/blog/1555060/202112/1555060-20211230210746171-1551210542.png)
查看log可知maven只会build当前module,所以其它module的依赖找不到。
![](https://img2020.cnblogs.com/blog/1555060/202112/1555060-20211230211759552-782480747.png)
解决方法
修改运行配置,运行前Build Project
。
![](https://img2020.cnblogs.com/blog/1555060/202112/1555060-20211230210752397-2144650690.png)
点击运行,可以从log中看到maven将其它module也build了,问题解决。
![](https://img2020.cnblogs.com/blog/1555060/202112/1555060-20211230212032215-1004919315.png)