maven工程<dependencyManagement>与<dependencies>区别
来源:互联网 发布:nbiot网络架构 编辑:程序博客网 时间:2024/06/04 23:55
Maven 使用dependencyManagement 元素来提供了一种管理依赖版本号的方式。通常会在一个组织或者项目的最顶层的父POM 中看到dependencyManagement 元素。使用pom.xml 中的dependencyManagement 元素能让
所有在子项目中引用一个依赖而不用显式的列出版本号。Maven 会沿着父子层次向上走,直到找到一个拥有dependencyManagement 元素的项目,然后它就会使用在这个dependencyManagement 元素中指定的版本号。
stackoverflow
In the parent POM, the main difference between the and is this:
Artifacts specified in the section will ALWAYS be included as a dependency of the child module(s).
Artifacts specified in the section, will only be included in the child module if they were also specified in the section of the child module itself. Why is it good you ask? because you specify the version and/or scope in the parent, and you can leave them out when specifying the dependencies in the child POM. This can help you use unified versions for dependencies for child modules, without specifying the version in each child module.e.g
<!-- ParentProj pom --><project> <dependencyManagement> <dependencies> <dependency> <!-- not much benefit defining alpha here, as we only use in 1 child, so optional --> <groupId>alpha</groupId> <artifactId>alpha</artifactId> <version>1.0</version> <exclusions> <exclusion> <groupId>zebra</groupId> <artifactId>zebra</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>charlie</groupId> <!-- not much benefit defining charlie here, so optional --> <artifactId>charlie</artifactId> <version>1.0</version> <type>war</type> <scope>runtime</scope> </dependency> <dependency> <!-- defining betaShared here makes a lot of sense --> <groupId>betaShared</groupId> <artifactId>betaShared</artifactId> <version>1.0</version> <type>bar</type> <scope>runtime</scope> </dependency> </dependencies> </dependencyManagement></project><!-- Child Proj1 pom --><project> <dependencies> <dependency> <groupId>alpha</groupId> <artifactId>alpha</artifactId> <!-- jar type IS DEFAULT, so no need to specify in child projects --> </dependency> <dependency> <groupId>betaShared</groupId> <artifactId>betaShared</artifactId> <type>bar</type> <!-- This is not a jar dependency, so we must specify type. --> </dependency> </dependencies></project><!-- Child Proj2 --><project> <dependencies> <dependency> <groupId>charlie</groupId> <artifactId>charlie</artifactId> <type>war</type> <!-- This is not a jar dependency, so we must specify type. --> </dependency> <dependency> <groupId>betaShared</groupId> <artifactId>betaShared</artifactId> <type>bar</type> <!-- This is not a jar dependency, so we must specify type. --> </dependency> </dependencies></project>
- maven工程<dependencyManagement>与<dependencies>区别
- mave工程dependencyManagement与dependencies区别
- maven中dependencies与dependencyManagement的区别
- Maven实战--- dependencies与dependencyManagement的区别
- Maven中dependencies与dependencyManagement的区别
- Maven中dependencies与dependencyManagement的区别
- Maven 中 dependencies 与 dependencyManagement 的区别
- maven父工程问题dependencymanagement 和dependencies区别
- Maven实战 --- dependencies与dependencyManagement
- Maven实战(六)--- dependencies与dependencyManagement的区别
- Maven实战(六)--- dependencies与dependencyManagement的区别
- Maven实战(六)--- dependencies与dependencyManagement的区别
- Maven深入学习(五)- dependencies与dependencyManagement的区别
- dependencies与dependencyManagement的区别
- dependencies与dependencyManagement的区别
- dependencies与dependencyManagement的区别
- dependencyManagement与dependencies的区别
- dependencies与dependencyManagement的区别
- 编译pixhawk遇到的问题,纠结好久才明白
- Java Websocket实例【项目实战系列】
- 【物志】--三国(258)
- 数字的比较,==与===比较
- 217. Contains Duplicate
- maven工程<dependencyManagement>与<dependencies>区别
- Shell[一]:zsh 每次打开Terminal都需要source bash_profile问题
- 一探前端开发中的JS调试技巧
- 为什么我们创业失败了和选择创业公司的思考
- 课本p287页
- js基础2
- 编程之战第七章 约瑟夫环(上)
- HDU 1232 畅通工程
- Android基础控件——SeekBar_1