:boot-docs: https://docs.spring.io/spring-boot/4.0-SNAPSHOT
:framework-api-docs: https://docs.spring.io/spring-framework/docs/7.0.x-SNAPSHOT/javadoc-api/org/springframework

= Spring Boot 4.0.0-M2 Release Notes

For changes in earlier milestones, please refer to:

- link:Spring-Boot-4.0.0-M1-Release-Notes[v4.0.0-M1]



== Upgrading from Spring Boot 3.5



=== Migration Guide

To help with upgrading, a https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide[migration guide] is available.



=== 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 https://www.elastic.co/docs/reference/elasticsearch/clients/java/transport/rest5-client/[`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 link:Spring-Boot-4.0.0-M2-Configuration-Changelog[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

Any interfaces annotated with `@org.springframework.web.service.registry.HttpServiceClient` are now automatically registered if they are found in packages scanned by Spring Boot auto-configuration.

We will be adding more documentation around this feature and general HTTP Service Client support in a later milestone.



=== API Versioning

Auto-configuration has been added for API Versioning {boot-docs}/reference/web/servlet.html#web.servlet.spring-mvc.api-versioning[with Spring MVC] and {boot-docs}/reference/web/reactive.html#web.reactive.webflux.api-versioning[with Spring WebFlux].
API Versioning can be configured using the `spring.mvc.apiversion.\*` or `spring.webflux.apiversion.*` properties.
For more advanced control, beans of type `ApiVersionResolver`, `ApiVersionParser` and `ApiVersionDeprecationHandler` can be defined. See the reference documentation ({boot-docs}/reference/web/servlet.html#web.servlet.spring-mvc.api-versioning[MVC], {boot-docs}/reference/web/reactive.html#web.reactive.webflux.api-versioning[WebFlux]) for further details.



=== spring-boot-autoconfigure-classic

A new module, `spring-boot-autoconfigure-classic` has been introduced.
It provides a similar experience to the less-modular Spring Boot 3 by providing access to all of Spring Boot's auto-configuration classes without the transitive dependencies to which they react



=== 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 OTLP.
It will also auto-configure the OpenTelemetry SDK.



=== Renamed Observability Modules

The following modules have been renamed:

- `spring-boot-metrics` -> `spring-boot-micrometer-metrics`
- `spring-boot-observation` -> `spring-boot-micrometer-observation`
- `spring-boot-tracing` -> `spring-boot-micrometer-tracing`

Each module's root package has also been updated:

- `org.springframework.boot.metrics` -> `org.springframework.boot.micrometer.metrics`
- `org.springframework.boot.observation` -> `org.springframework.boot.micrometer.observation`
- `org.springframework.boot.tracing` -> `org.springframework.boot.micrometer.tracing`



=== Dependency Upgrades

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

* https://github.com/micrometer-metrics/micrometer/releases/tag/v1.16.0-M2[Micrometer 1.16.0-M2]
* https://github.com/micrometer-metrics/tracing/releases/tag/v1.6.0-M2[Micrometer Tracing 1.6.0-M2]
* https://github.com/reactor/reactor/releases/tag/2025.0.0-M6[Reactor 2025.0.0-M6]
* https://github.com/spring-projects/spring-authorization-server/releases/tag/2.0.0-M2[Spring Authorization Server 2.0.0-M2]
* https://github.com/spring-projects/spring-batch/releases/tag/v6.0.0-M2[Spring Batch 6.0.0-M2]
* https://github.com/spring-projects/spring-data-bom/releases/tag/2025.1.0-M5[Spring Data 2025.1.0-M5]
* https://github.com/spring-projects/spring-framework/releases/tag/v7.0.0-M8[Spring Framework 7.0.0-M8]
* https://github.com/spring-projects/spring-graphql/releases/tag/v2.0.0-M2[Spring GraphQL 2.0.0-M2]
* https://github.com/spring-projects/spring-integration/releases/tag/v7.0.0-M2[Spring Integration 7.0.0-M2]
* https://github.com/spring-projects/spring-ldap/releases/tag/4.0.0-M2[Spring LDAP 4.0.0-M2]
* https://github.com/spring-projects/spring-pulsar/releases/tag/v2.0.0-M2[Spring Pulsar 2.0.0-M2]
* https://github.com/spring-projects/spring-restdocs/releases/tag/v4.0.0-M2[Spring RESTDocs 4.0.0-M2]
* https://github.com/spring-projects/spring-security/releases/tag/7.0.0-M2[Spring Security 7.0.0-M2]
* https://github.com/spring-projects/spring-session/releases/tag/4.0.0-M2[Spring Session 4.0.0-M2]

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

* https://docs.couchbase.com/java-sdk/current/project-docs/sdk-release-notes.html[Couchbase Client 3.9]
* https://www.elastic.co/docs/release-notes/elasticsearch/clients/java/9-1-0[Elasticsearch Client 9.1]
* https://documentation.red-gate.com/flyway/release-notes-and-older-versions/release-notes-for-flyway-engine[Flyway 11.11]
* https://github.com/graphql-java/graphql-java/releases/tag/v25.0.beta-5[GraphQL 25.0 (beta)]
* https://github.com/hibernate/hibernate-orm/releases/tag/7.1.0[Hibernate 7.1]
* HikariCP 7.0
* https://github.com/HtmlUnit/htmlunit/releases/tag/4.15.0[HtmlUnit 4.15.0]
* https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.20[Jackson 2.20 (rc)]
* https://github.com/jetty/jetty.project/releases/tag/jetty-12.1.0[Jetty 12.1]
* https://github.com/netplex/json-smart-v2/releases/tag/2.6.0[Json-smart 2.6.0]
* https://github.com/lettuce-io/lettuce-core/releases/tag/6.8.0.RELEASE[Lettuce 6.8]
* https://github.com/microsoft/mssql-jdbc/releases/tag/v13.2.0[MSSQL JDBC 13.2]
* https://github.com/graalvm/native-build-tools/releases/tag/0.11.0[Native Build Tools Plugin 0.11]
* https://github.com/SeleniumHQ/htmlunit-driver/releases/tag/4.35.0[Selenium HtmlUnit 4.35]



=== 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`.
* A `logging.console.enabled` property has been introduced. Setting it to `false` disables console logging.


== Deprecations in Spring Boot 4.0.0-M2

* None