您的位置:首页 > 其它

有关dependencies和dependencyManagement简单介绍

2016-07-19 23:46 429 查看
最近在项目中操作maven工程的父工程与子工程的pom.xml依赖传递时,在父亲项目配置:

<dependencyManagement>

<dependencies>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-test</artifactId>

<version>2.5.6</version>

<type>jar</type>

<scope>test</scope>

</dependency>

</dependencies>
</dependencyManagement>

在子项目下如果pom文件中不显示声明是不会传递依赖,而如果父项目配置:

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>2.5.6</version>
<type>jar</type>
<scope>test</scope>
</dependency>
</dependencies>

在子项目会发现此依赖包,因此只配置 <dependencies>和</dependencies>时,子项目会从父项目中继承该依赖,而如果加上<dependencyManagement>和</dependencyManagement>时,子项目是需要显示声明才能依赖父项目中的依赖。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: