Using <dependencyManagement> and Exclusions in Maven to Resolve Version Conflicts
Centralise dependency versions with <code><dependencyManagement></code> and drop unwanted transitive libraries using <code><exclusion></code>. A worked POM example shows how to keep a multi‑module build conflict‑free, with verification steps and common pitfalls highlighted.
24 May 2026, 04:14 UTC

What You Can Achieve
In a multi‑module Maven project, <dependencyManagement> lets you centralise a single version for a dependency that all modules inherit. Coupled with <exclusion> entries, you can drop unwanted transitive libraries and keep the classpath lean and conflict‑free.
How It Works
When Maven builds a project, it first merges the parent POMs into an effective POM. The <dependencyManagement> section is not a direct dependency; it only supplies default values (version, scope, exclusions) for dependencies that appear elsewhere in the project. If a module declares <dependency> without a version, Maven will look up the version in <dependencyManagement>. Exclusions declared in a dependency entry prevent Maven from pulling in that transitive artifact.
Worked Example
Consider a parent project that uses two different modules. Both modules need org.slf4j:slf4j-api, but one also pulls in org.slf4j:slf4j-log4j12 transitively, which conflicts with the project's preferred ch.qos.logback:logback-classic implementation. The following POM resolves the conflict.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.