轉載於:https://www.jianshu.com/p/6215af9801a0
一、在父模塊pom中使用的導包方式為:
<!-- 在父pom中的dependencies標簽中的jar配置,子pom會直接繼承 --> <depedencies> ... </depedencies>
子模塊會直接繼承父模塊中的jar包
此種方式一般用於:在父pom中配置每個模塊都需要的jar包及其他配置信息
二、在父模塊pom中使用的導包方式為:
<dependencyManagement> <dependencies> ... </dependencies> </dependencyManagement>
子模塊pom不會自動繼承父模塊pom中的jar包,如果需要使用,就要給出 groupId 和 artifactId,無需給出 version
此種方式由父模塊統一管理依賴的版本配置
總結
Maven <dependencyManagement> 與 <dependencies> 區別
<dependencies>中的jar直接加到項目中,管理的是依賴關系。(如果有父pom、子pom,則子pom中只能被動接受父pom的版本)
<dependencyManagement>主要管理版本,對於子模塊繼承同一個父模塊是很有用的,集中管理依賴版本不添加依賴關系,對於其中定義的版本,子pom不一定要繼承父pom所定義的版本。
作者:緘默_8421
鏈接:https://www.jianshu.com/p/6215af9801a0
來源:簡書
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。