sof
sof

Reputation: 9649

Maven direct and transitive dependencies resolution

Artifact_A has both the direct dependency and the transitive dependency on Artifact_B within the same scope.

Does the direct dependency always precede the transitive dependency, or the one of higher version prevail?

Is there any reference with better illustration on Maven Dependencies Resolution than the chapter Maven reference manual - Project Dependencies?

Upvotes: 2

Views: 1219

Answers (1)

The dependency-resolution mechanism can be complicated. If there's a managed version (dependencyManagement), then that will take precedence. Generally speaking, Maven will use the highest-requested version that satisfies all of the requirements (for example, some servlet package might require [2.4,3.0) while another package requires 2.5, so Maven will use 2.5). If Maven can't find such a version (in the above sample, if the second package required [3.0,4.0)), then it will produce an error.

If you have a specific issue that you're running into, feel free to post a question with all the details.

Upvotes: 3

Related Questions