Skip to content

Spring Boot 4.0.0 M2 Release Notes

Moritz Halbritter edited this page Aug 20, 2025 · 17 revisions

Spring Boot 4.0.0-M2 Release Notes

Upgrading from Spring Boot 3.5

Minimum Requirements Changes

  • Gradle 8.x (8.14 or later) or 9.x

Removed Support for javax.annotations.NonNull and org.springframework.lang.Nullable

Actuator endpoint parameters no longer can use javax.annotations.NonNull to declare that a parameter is optional. This includes the now deprecated org.springframework.lang.Nullable. If you are using this annotation, you should migrate to either OptionalParameter, or org.jspecify.annotations.Nullable.

Removed Support for Undertow

Spring Boot 4.0 requires a Servlet 6.1 baseline, with which Undertow is not yet compatible. As a result, Undertow support is dropped, including the undertow starter and the ability to use Undertow as an embedded server. We do not recommend deploying Spring Boot 4.0 applications to a non-Servlet 6.1 compliant container.

Elasticsearch Client

In response to changes in Elasticsearch, auto-configuration for the now-deprecated low-level Elasticsearch RestClient has been replaced with auto-configuration for the new Rest5Client. If you were using Spring Boot’s RestClientBuilderCustomizer to customize the client, you must now use Rest5ClientBuilderCustomizer instead.

As part of the changes in Elasticsearch, the client code has been consolidated in the co.elastic.clients:elasticsearch-java module, including built-in sniffer support. The org.elasticsearch.client:elasticsearch-rest-client and org.elasticsearch.client:elasticsearch-rest-client-sniffer modules are no longer required and Spring Boot’s dependency management for them has been removed.

Support for the higher-level ElasticsearchClient and the Spring Data Elasticsearch-provided ReactiveElasticsearchClient remains. It has been updated to use the new low-level client.

Kafka Streams Customization

Spring Boot’s StreamBuilderFactoryBeanCustomizer has been removed in favor of Spring Kafka’s StreamsBuilderFactoryBeanConfigurer. When migrating to the new configurer, be aware that it implements Ordered with a default value of 0.

JSpecify Nullability annotations

Spring Boot 4.0.0-M2 adds JSpecify nullability annotations. If you’re using a null checker in your build or using Kotlin, this could lead to compilation failures because of now nullable or non-nullable types.

Logback Default Charset

The default Charset for Logback has been harmonized with the behavior of Log4j2. By default, the charset of a log file is UTF-8. For console log, we use the Console#charset() if it is available, otherwise we use UTF-8.

New and Noteworthy

Tip
Check the configuration changelog for a complete overview of the changes in configuration.

Actuator Endpoint Optional Parameters

Actuator endpoint parameters can be flagged optional using the new, technology-independent, OptionalParameter annotation. If you are using JSpecify, you can also use org.jspecify.annotation.Nullable. Finally, Kotlin null safety is now supported as well.

Gradle 9

Gradle 9 is now supported for building Spring Boot applications. Support for Gradle 8.x (8.14 or later) remains.

@HttpServiceClient annotation support

TODO we now scan for the annotation

API Versioning

TODO we have properties

OpenTelemetry starter

A new starter, spring-boot-starter-opentelemetry has been added. This starter brings in all necessary dependencies to export metrics and traces over OLTP. It will also auto-configure the OpenTelemetry SDK.

Dependency Upgrades

Spring Boot 4.0.0-M2 moves to new versions of several Spring projects:

Numerous third-party dependencies have also been updated, some of the more noteworthy of which are the following:

Miscellaneous

Apart from the changes listed above, there have also been lots of minor tweaks and improvements including:

  • Public members (aside from constants) have been removed from auto-configuration classes. Auto-configurations never have been public API and now this is enforced through Java mechanisms.

  • Auto-configured HTTP clients backed by the JDK HttpClient are now configured to use virtual threading when spring.threads.virtual.enabled is true.

Deprecations in Spring Boot 4.0.0-M2

*

Clone this wiki locally