After upgrading an application to Spring Boot 4.0, applications running on Tanzu Application Service / Elastic Application Runtime fail to start with the following error:
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.restclient.RestTemplateBuilder
This error typically occurs during startup, before the application begins serving requests.
Spring Boot 4.0.0 – 4.0.1
Applications including:
spring-boot-starter-cloudfoundry
Applications not using the Cloud Foundry actuator integration are generally not affected.
In Spring Boot 4.0, several components were modularized and moved out of spring-boot-autoconfigure.
As part of this change, RestTemplateBuilder was moved into the new module: spring-boot-starter-restclient
The spring-boot-starter-cloudfoundry starter relies on RestTemplateBuilder for Cloud Foundry actuator communication, but in Spring Boot 4.0.0 and 4.0.1 it does not explicitly declare this dependency.
As a result, when an application includes spring-boot-starter-cloudfoundry without explicitly declaring the rest client starter, the class is missing at runtime, leading to a ClassNotFoundException.
This issue is tracked upstream in the Spring Boot project:
Applications using spring-boot-starter-cloudfoundry must explicitly declare the REST client starter.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-restclient</artifactId>
</dependency>
After adding the dependency, rebuild and redeploy the application.
Spring Boot 4.0.2, that will be released in January 22nd. 2026.
Starting with Spring Boot 4.0.2, spring-boot-starter-cloudfoundry correctly declares its dependency on the REST client module.
Applications upgrading to 4.0.2 or later do not need to add spring-boot-starter-restclient explicitly.
This behavior is tracked in the Spring Boot issue: