Maven父子工程install编译问题

Maven父子工程install编译问题

异常信息

[WARNING] The requested profile "nexus" could not be activated because it does not exist.
[ERROR] Failed to execute goal on project NettyDemos: Could not resolve dependencies for project com.crazymakercircle:NettyDemos:jar:1.0-SNAPSHOT: Failed to collect dependencies at com.crazymakercircle:chatcommon:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for com.crazymakercircle:chatcommon:jar:1.0-SNAPSHOT: Could not find artifact com.crazymakercircle:crazyCircleDemos:pom:1.0-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

异常分析

由于项目是Maven模块化工程,子模块相互依赖,编译子工程 NettyDemos时,由于依赖的工程chatcommon没有install进本地仓库或远程私服,所以出现无法找到依赖异常。简单的来说就是A依赖B,但是B在本地仓库或远程私服没有,所以出现异常。

异常解决

知道原因了,问题解决起来就很方便了嘛。直接install一下缺失的依赖工程即可。但是细心的小伙伴很快就发现。哎,怎么chatcommon(B) install成功之后,再install NettyDemos(A)仍然出现上面的异常呢?这是因为父工程没有清理。所以要想install成功,需要先运行父工程的maven clean。之后再在子工程运行maven install即可。

总结

Maven工程最好新建一个父工程,便于开发和打包。Java小白一个,如果有哪里解释的不对,还请多多指教。

发布了22 篇原创文章 · 获赞 4 · 访问量 22万+

猜你喜欢

转载自blog.csdn.net/qq_32510597/article/details/104970866