After upgrade to Spring Boot 3.4.0 from 3.3.x, I get an error
Cannot resolve com.squareup.okhttp3:mockwebserver:unknown
My project uses okhttp3.mockwebserver.MockWebServer
and has the dependency
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
</dependency>
I have not changed anything else but the Spring Boot version, and everything has worked OK until now.
The reason is described in the Spring Boot 3.4 Release Notes:
OkHttp Dependency Management Removed
Spring Boot no longer depends on OkHttp so it no longer manages its version. If your application has OkHttp dependencies, update its build to use an OkHttp version that meets its needs.
It means that until the version 3.3.x, the Spring Boot Dependencies BOM spring-boot-dependencies-3.3.5.pom
contained the dependency management:
<properties>
...
<okhttp.version>4.12.0</okhttp.version>
...
</properties>
...
<dependencyManagement>
...
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp-bom</artifactId>
<version>${okhttp.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
...
</dependencyManagement>
What you need to do now is to add the version explicitly to your pom.xml
:
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>4.12.0</version>
<scope>test</scope>
</dependency>
Of course use the current version of mockwebserver
, 4.12.0
is just an example as of the date of the answer.