Application fails to start with 'ClassNotFoundException: RestTemplateBuilder' when using spring-boot-starter-cloudfoundry on Spring Boot 4.0
search cancel

Application fails to start with 'ClassNotFoundException: RestTemplateBuilder' when using spring-boot-starter-cloudfoundry on Spring Boot 4.0

book

Article ID: 425661

calendar_today

Updated On:

Products

VMware Tanzu Platform - Cloud Foundry

Issue/Introduction

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.

Environment

  • 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.

Cause

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:

Resolution

Explicitly add the missing dependency (Spring Boot 4.0.0 / 4.0.1)

Applications using spring-boot-starter-cloudfoundry must explicitly declare the REST client starter.

Maven

 
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-restclient</artifactId>
</dependency>
 

Gradle

 
 
implementation("org.springframework.boot:spring-boot-starter-restclient")

After adding the dependency, rebuild and redeploy the application.

 

Fixed In

  • 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.

Additional Information

This behavior is tracked in the Spring Boot issue: