dependencies
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
Dependency management
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8</version>
</dependency>
</dependencies>
</dependencyManagement>
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.
In the parent POM, the main difference between the <dependencies> and <dependencyManagement> is this:
- Artifacts specified in the <dependencies> section will ALWAYS be included as a dependency of the child module(s).
- 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?
- 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
- <dependencyManagement> allows to easily upgrade/downgrade dependencies based on need, in other scenario this needs to be exercised at every child pom level