Maven项目中Lifecycle和Plugins下的install的区别

在Maven中,如果你的web和service在不同的模块下,如果直接用用tomcat插件运行web层,那么运行时会报错

Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install (default-cli) on project springboot: The packaging for this project did not assign a file to the build artifact
[ERROR] Failed to execute goal on project dubbo-web: Could not resolve dependencies for project org.example:dubbo-web:war:1.0-SNAPSHOT: Could not find artifact org.example:dubbo-service:jar:1.0-SNAPSHOT -> [Help 1]

[ERROR] Failed to execute goal on project dubbo-web: Could not resolve dependencies for project org.example:dubbo-web:war:1.0-SNAPSHOT: Could not find artifact org.example:dubbo-service:jar:1.0-SNAPSHOT -> [Help 1]

Maven项目中Lifecycle和Plugins下的install的区别_第1张图片
 提示你找不到service的包,因为service虽然写好了,Idea没有报错,但是在本地maven仓库是没有service的包的,web在启动的时候就无法启动。

 Maven项目中Lifecycle和Plugins下的install的区别_第2张图片

 

所以需要将service先安装到本地仓库

 但在安装的时候,会发现有两个install,一个在Lifecycle里面,一个在Plugins里面,

如果在Plugins里面安装会出现问题,因为Plugins安装,只会执行安装操作,而maven生命周期安装之前的操作都不会执行 ,就会安装失败

The packaging for this project did not assign a file to the build artifact


而在lifecycle里面安装,maven会连带install之前的操作一并执行,这样就能成功安装,你就能在本地仓库找到你的包了

 
 

你可能感兴趣的:(idea,maven,java)