When I use Maven versions:display-dependency-updates
to check dependencies updates, I get two sections of result.
1st:
The following dependencies in Dependency Management have newer versions:
2nd:
The following dependencies in Dependencies have newer versions:
What's the difference between these two?
The Dependency section of the POM defines the artifacts (jars, zip etc) upon which your project depends. i.e. the artifacts that it requires to compile, run etc.
The Dependency Management section of the POM is used to manage dependency information.
So for example, in the following pom the JUnit dependency is defined completely in the
dependencyManagement
section of the POM withversion=4.11
andscope = test
.In the
dependency
section you simply need to define the JUnit dependency using thegroupId
andartifactId
and maven automatically picks up the version and scope from thedependencyManagement
section.Usually you would define the
dependencyManagement
section in a parent POM, where you define the version and scope for all dependencies. Then in the child module's you simply need to define the dependencies using thegroupId
andartifactId
. This allows you to centrally manage versions and means you only have to update them in one place.All of this is far better explained in the maven documentation: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
The Versions Maven Plugin is simply listing the versions found in each of these sections, as it is possible in the
dependencies
section to override theversion
that was defined in thedependencyManagement
section.