Home > Enterprise >  Maven not resolving given nested dependency version
Maven not resolving given nested dependency version

Time:12-23

I have given following module in module A:

<dependencies>
    <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>4.9.2</version>
    </dependency>
</dependecies>

And included module A in module B like:

<dependencies>
    <dependency>
        <groupId>com.example.test</groupId>
        <artifactId>A</artifactId>
        <version>1.01</version>
    </dependency>
</dependecies>

But still mvn dependency:tree is showing 3.14.9 version in module B, please help.

[INFO] com.example.test:B:jar:1.01
[INFO]  - com.example.test:A:jar:1.01:compile
[INFO] |   - com.squareup.okhttp3:okhttp:jar:3.14.9:compile

I have also excluded it from all other modules that have 3.14.9 conflicts. I know I can add okhttp 4.9.2 explicitly in module B but there are many such modules, I don't want to add explicitly 4.9.2 version each time. For some reason, this is the case only for okhttp, rest other dependencies resolving given version

CodePudding user response:

I don't see the version of artefact A you are trying to use in module B, can you check if it's the same version you are trying to build using okhttp 4.9.2

CodePudding user response:

I solved the dependency resolution by enforcing dependency version in dependencyManagement in parent pom as mentioned in https://stackoverflow.com/a/2684291/5859017 in 2nd point. Maybe some dependency in parent pom was causing problem that has okhttp as transitive dependency.

  • Related