Skip to content
Latchkey

mvn dependency:tree: Inspect the Dependency Graph

mvn dependency:tree prints the resolved dependency graph and annotates which transitive versions were omitted for conflict or duplication.

dependency:tree is the first command to run when a transitive version is wrong. The "omitted for conflict with" notes explain exactly what Maven picked and why.

What it does

The maven-dependency-plugin's tree goal resolves the project dependencies and prints them as a tree. It marks entries "(omitted for conflict with X)" or "(omitted for duplicate)" so you can see where Maven's nearest-wins resolution discarded a version.

Common usage

Terminal
mvn dependency:tree
mvn dependency:tree -Dincludes=com.google.guava:guava
mvn dependency:tree -Dverbose -Dincludes=:slf4j-api
mvn dependency:tree -DoutputFile=tree.txt

Flags

FlagWhat it does
-Dincludes=<g:a>Filter to matching dependencies
-Dexcludes=<g:a>Hide matching dependencies
-DverboseShow omitted/conflict nodes (slower)
-DoutputFile=<file>Write the tree to a file
-Dscope=<scope>Limit to one scope (e.g. compile)

In CI

When an enforcer convergence check or a CVE scan fails, run mvn dependency:tree -Dverbose -Dincludes=<artifact> to find the path that drags in the bad version, then exclude it or pin via dependencyManagement. Capture -DoutputFile output as a job artifact.

Common errors in CI

"Could not resolve dependencies for project" means resolution failed before the tree could print (network or auth); fix that first. An empty filtered tree means -Dincludes did not match; the format is groupId:artifactId (a leading colon matches any group, e.g. :slf4j-api). The plugin needs ~/.m2 populated, so warm the cache offline-first.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →