ysfseu
ysfseu

Reputation: 676

maven transitive dependency wrong version

I deployed a jar A with the following dependency:

<dependency>
  <groupId>io.projectreactor</groupId>
  <artifactId>reactor-core</artifactId>
  <version>3.3.1.RELEASE</version>
</dependency>

I have another project B and project C both with dependency to A. So the structure is as following:

B -> A -> reactor-core

C -> A -> reactor-core

The problem is the version of reactor-core is different in project B and project C. In B, its version is 2.0.8. In C it's 3.3.1 . In fact, I have excluded the version 2.0.8 in project A. I don't know why it still appears.

Upvotes: 0

Views: 644

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35785

Don't use excludes. They are hard to manage.

Look at the dependency tree (mvn dependency:tree). You will reactor-core at different places with different versions. Maven "mediates" this tree and chooses the "nearest" version.

If you don't want this behaviour (actually, you often don't want that), make an entry in <dependencyManagement> with the correct version. This will override all transitive versions and you get the version you want. You do not need exclusions for that.

Upvotes: 2

Related Questions