Maven Best Practice for Resolving Transitive Dependency Conflicts

Tag: maven Author: qq8099227 Date: 2012-12-04

Suppose I have the following:

A -> B,C,D,E

B -> F[1.1]
C -> F[1.0.1]
D -> F[1.2]
E -> F[1.1]

I know of 2 ways to resolve the transitive dependency conflict: 1. Add excludes to all but 1 of A's dependencies 2. Use dependencyManagement to specify the version of F that I really want.

Which of these options is better practice?

Other Answer1

The best practice is to add the version you want to use to your DependencyManagement section of your pom. This will ensure you're getting what you want, especially if one of your dependencies upgrade their version. You should still run the dependency plugin now and then (I like the tree goal) to see if the versions change so that you can adjust your version as needed.