This is a duplicate of, or maybe closely related to #5379 and #4305.
mockwebserver version 4.3.1 depends on the wrong version of okhttp.
+- com.squareup.okhttp3:mockwebserver:jar:4.3.1:test
| \- com.squareup.okhttp3:okhttp:jar:3.8.1:test
| \- com.squareup.okio:okio:jar:1.13.0:test
If you include a current okhttp:4.3.1 there is a kotlin stdlib version clash:
+- com.squareup.okhttp3:okhttp:jar:4.3.1:test
| +- com.squareup.okio:okio:jar:2.4.1:test
| | \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.3.50:test
| \- org.jetbrains.kotlin:kotlin-stdlib:jar:1.2.71:test
| \- org.jetbrains:annotations:jar:13.0:compile
Note the kotlin-stdlib-common:1.3.50 vs. kotlin-stdlib:1.2.71.
So, in order to get a clean state you would have to do the following in maven:
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>${okhttp3.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp3.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.3.50</version>
<scope>test</scope>
</dependency>
+- com.squareup.okhttp3:mockwebserver:jar:4.3.1:test
+- com.squareup.okhttp3:okhttp:jar:4.3.1:test
| \- com.squareup.okio:okio:jar:2.4.1:test
+- org.jetbrains.kotlin:kotlin-stdlib:jar:1.3.50:test
| +- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.3.50:test
| \- org.jetbrains:annotations:jar:13.0:compile
Can you please fix the versions in mockwebserver's dependencies?
I see the dependency on OkHttp 4.3.1.
https://search.maven.org/artifact/com.squareup.okhttp3/mockwebserver/4.3.1/jar
Is it possible you鈥檙e getting 3.8.1 through some other dependency?
@KaiStapel I ran into the same issue. Looking at the mockwebserver pom though, it was clear that the dependency definition was coming from somewhere else.
After digging further into my dependencies, I noticed that the Spring Boot parent org.springframework.boot:spring-boot-dependencies:2.2.2.RELEASE defines the okhttp3 dependency as
<okhttp3.version>3.14.4</okhttp3.version>
which overrides the transitive one from the mockwebserver. It also does the same for other okhttp3 components which means that you need to declare them explicitly in your own pom if you want to ensure that you use the correct ones that are defined transitively.
@benze Thanks for digging into this. 馃憤
Most helpful comment
@KaiStapel I ran into the same issue. Looking at the mockwebserver pom though, it was clear that the dependency definition was coming from somewhere else.
After digging further into my dependencies, I noticed that the Spring Boot parent
org.springframework.boot:spring-boot-dependencies:2.2.2.RELEASEdefines the okhttp3 dependency as<okhttp3.version>3.14.4</okhttp3.version>which overrides the transitive one from the mockwebserver. It also does the same for other okhttp3 components which means that you need to declare them explicitly in your own pom if you want to ensure that you use the correct ones that are defined transitively.