The dependencyManagement section of a Maven pom.xml declares the versions (and scopes and exclusions) of dependencies in one place without adding those dependencies to the project. Any module that later lists the same groupId and artifactId in its own dependencies block can omit the version and inherits the managed one. This keeps versions consistent across a multi-module build.
It is also the mechanism behind Bill of Materials (BOM) imports, such as the Spring Boot dependencies BOM.
Maven has two places to list dependencies, and they behave differently:
| Element | Effect |
|---|---|
dependencies | Adds the artifact to the classpath of this module |
dependencyManagement | Only records defaults (version, scope, exclusions) for artifacts that are declared elsewhere |
Declaring a library in dependencyManagement alone does not put it on any classpath. It only answers the question "if someone uses this artifact, which version should they get?". The managed values also apply to transitive dependencies, so a managed version can override the version a library would otherwise pull in.
Put dependencyManagement in the parent POM of a multi-module project. Child modules refer to the parent and then declare dependencies without versions.
A child module then uses the artifacts without a version:
The version numbers above are examples. Use the current releases when you build your own project. To upgrade a library for every module, you change one line in the parent.
A BOM is a POM that contains only a dependencyManagement section. Because Maven allows a project only one parent, you import additional BOMs with <scope>import</scope> and <type>pom</type> inside your own dependencyManagement:
This is how you get Spring Boot's tested set of versions without inheriting from spring-boot-starter-parent. If you do use the starter parent, the same management is already inherited. Other well-known BOMs include the Jakarta EE, JUnit and Testcontainers BOMs.
The order of precedence is simple: a version written directly in a module's dependencies entry wins over the managed one. Prefer a property override if the BOM exposes one, for example in a Spring Boot project:
You can also add exclusions in dependencyManagement, and they apply to every module that uses the artifact.
Do not assume the managed version was picked. Inspect it:
dependency:tree shows the version each module ends up with, and help:effective-pom shows the merged result of parents and imports. Related sections exist for build tools: pluginManagement plays the same role for plugins.
dependencies adds artifacts to the build. dependencyManagement only fixes their versions and settings for modules that declare them.
Not strictly, but importing a BOM there is still the cleanest way to keep related libraries on compatible versions.
A version declared directly in the child, or a different path in the dependency tree, may win. Run mvn dependency:tree to see why.
No. A BOM is a POM that uses dependencyManagement to publish a set of versions. You consume it with scope import.
dependencyManagement centralises dependency versions, scopes and exclusions so modules stay consistent. Use it in a parent POM, import BOMs with scope import, keep child declarations version-free, and verify the result with mvn dependency:tree.