Differences between dependencymanagement and dependencies in maven
2017-10-12 10:08
916 查看
In dependencyManagement you declare dependency versions, exclusions and other things that let you manage them in place (e.g. a parent pom) for multiple projects.
Dependency Management allows to consolidate and centralize the management of dependency versions without adding dependencies which are inherited by all children. This is especially useful when you have a set of projects (i.e. more than one) that inherits
a common parent.
Another extremely important use case of dependencyManagement is the control of versions of artifacts used in transitive dependencies. This is hard to explain without an example. Luckily, this is illustrated in the documentation.
Artifacts specified in the <dependencyManagement> section, will only be included in the child module if they were also specified in the <dependencies> 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.
In dependencies you then declare the actual usage/need of a dependency and if the dependency is managed in a parent pom you can do so without using a version and it will be inherited and therefore be consistant across your usages downstream of the the parent
pom.
A dependency defined under the dependencyManagement can be used in it's child modules without specifying the version.
Artifacts specified in the <dependencies> section will ALWAYS be included as a dependency of the child module(s).
references: https://stackoverflow.com/questions/2619598/differences-between-dependencymanagement-and-dependencies-in-maven
Dependency Management allows to consolidate and centralize the management of dependency versions without adding dependencies which are inherited by all children. This is especially useful when you have a set of projects (i.e. more than one) that inherits
a common parent.
Another extremely important use case of dependencyManagement is the control of versions of artifacts used in transitive dependencies. This is hard to explain without an example. Luckily, this is illustrated in the documentation.
Artifacts specified in the <dependencyManagement> section, will only be included in the child module if they were also specified in the <dependencies> 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.
In dependencies you then declare the actual usage/need of a dependency and if the dependency is managed in a parent pom you can do so without using a version and it will be inherited and therefore be consistant across your usages downstream of the the parent
pom.
A dependency defined under the dependencyManagement can be used in it's child modules without specifying the version.
Artifacts specified in the <dependencies> section will ALWAYS be included as a dependency of the child module(s).
references: https://stackoverflow.com/questions/2619598/differences-between-dependencymanagement-and-dependencies-in-maven
相关文章推荐
- Find the difference between two days in days, months and years
- difference between Abstract class and interface in java
- Maven dependencyManagement和dependencies的区别
- Difference between Association, Composition and Aggregation in Java, UML and Object Oriented Program
- Difference Between Class.ForName() And ClassLoader.LoadClass() Methods In Java
- The difference between an Isolated host and an In-Process host...
- Difference between applicationContext.xml and spring-servlet.xml in Spring
- The difference between iostream and stdio in MPI
- difference between <? super T> and <? extends T> in Java
- Difference between HashSet and HashMap in Java
- Difference Between objectForKey and valueForKey in NSDictionary
- Difference between prop and attr in different version of jquery
- Difference between event.target and event.currentTarget properties in an event object.
- Difference between Stack and Heap memory in Java
- The differences between new(delete) and malloc(free) in c/c++
- Java - Difference between throw and throws in Exception handling
- Difference between HashMap, LinkedHashMap and TreeMap in Java
- Difference between Set, List and Map in Java - Interview question
- Difference between Truncate and Delete command in SQL - Interview Questions with Example
- difference between Abstract class and interface in java