1

I deploy my maven project to a maven private server. After introducing dependencies in other projects, the version of okhttp3 changed from 4.7.2 to 3.14.9

The maven dependency of the deployed project:mdm-auth-spring-boot-starter

Another project introduces mdm-auth-spring-boot-starter

Why has the version of okhttp3 has changed?

My OS is Win10, JDK_version-1.8.181, maven version 3.6.3

Reinstalling the system, JDK and maven, doesn't solve the problem.

tijko
  • 7,599
  • 11
  • 44
  • 64
zhucf
  • 11
  • 2
  • Does this answer your question? [How to override Spring Boot dependencies default version?](https://stackoverflow.com/questions/39613498/how-to-override-spring-boot-dependencies-default-version) – Joe Jun 21 '20 at 11:55

2 Answers2

4

The spring-boot-starter-parent:2.3.1-RELEASE that you extend manages the version of com.squareup.okhttp3:okhttp to 3.14.9 via spring-boot-dependencies:

<okhttp3.version>3.14.9</okhttp3.version>
...
  <dependencyManagement>
    <dependencies>
...
      <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>${okhttp3.version}</version>
      </dependency>
...
    </dependencies>
  </dependencyManagement>

This is documented under dependency management:

Each release of Spring Boot provides a curated list of dependencies that it supports. In practice, you do not need to provide a version for any of these dependencies in your build configuration, as Spring Boot manages that for you.

You'll need to either accept that, and work with that version, or set the okhttp3.version property in your project for the okhtttp version that you'd like to build with.

Joe
  • 29,416
  • 12
  • 68
  • 88
0

The problem might be in transitive dependencies (some other dependency has a dependeny to okhttp3 3.14.9 and it can overriede 4.7.2 ) You can try to execute mvn dependency:tree -Dverbose=true https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html and find, which versions of okhttp3 you have, and see which other dependency brought 3.14.9 version.