-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Spring Boot 4.0 Draft Release Notes
Since this is a major release of Spring Boot, upgrading existing applications can be a little more involved that usual. We’ve put together a dedicated migration guide to help you upgrade your existing Spring Boot 3.5 applications.
If you’re currently running with an earlier version of Spring Boot, we strongly recommend that you upgrade to Spring Boot 3.5 before migrating to Spring Boot 4.0.
Tip
|
Check the configuration changelog for a complete overview of the changes in configuration. |
Starting with 4.0.0-M1, all Spring Boot milestones (and release candidates) are now published to Maven Central in addition to https://repo.spring.io. This should make it easier to try new milestones in the 4.x line as they become available.
Gradle 9 is now supported for building Spring Boot applications. Support for Gradle 8.x (8.14 or later) remains.
Spring Boot now includes auto-configuration support and configuration properties for HTTP Service Clients. HTTP Service Clients allow you to annotate plain Java interfaces and have Spring automatically create implementations of them.
For example, the following interface can be used to call an "echo" service:
@HttpExchange(url = "https://echo.zuplo.io")
public interface EchoService {
@PostExchange
Map<?, ?> echo(@RequestBody Map<String, String> message);
}
For full details of the feature, please see the updated documentation.
Auto-configuration has been added for API Versioning with Spring MVC and 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.
The auto-configuration for JMS now includes support for the new JmsClient
API.
The support for JmsTemplate
and JmsMessagingTemplate
is left unchanged.
The auto-configurations for task scheduling and task execution now support multiple TaskDecorator
beans.
When the context contains multiple TaskDecorator
beans, a CompositeTaskDecorator
that delegates to them is created.
The individual decorators are called in the ordered defined by @Order
and Ordered
.
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.
It is now possible for @ConfigurationProperties
-annotated types to refer to types that are located in a different module.
To source the metadata from those modules, you should add the annotation processor (if necessary) and flag the type with @ConfigurationPropertiesSource
.
See the reference documentation for more details.
Support for the certificate validity threshold has been removed from the SSL info contribution.
A certificate that had a status of WILL_EXPIRE_SOON
will now appear as VALID
.
The information about the start and end of a certificate’s validity remains.
Certificate chains that contain one or more certificates that will expire within the configured threshold (management.health.ssl.certificate-validity-warning-threshold
) are
now listed in a new expiringChains
entry in the details of the health response.
The status WILL_EXPIRE_SOON
is no longer used and expiring certificates will have a status of VALID
.
The MongoDB health indicators have been reworked so that they no longer require Spring Data MongoDB. This allows health information to be provided when using the MongoDB Java Driver directly.
As part of this change, the health indicators have moved from spring-boot-data-mongodb
to spring-boot-mongodb
.
Their packages have also been updated accordingly.
A new property, spring.data.mongodb.representation.big-decimal
, has been introduced to control how Spring Data MongoDB stores BigDecimal
(and BigInteger
) values in MongoDB.
A number of properties have also been renamed. See the migration guide for details.
Spring Boot now ships a new "spring-boot-kotlin-serialization" module and corresponding "spring-boot-kotlin-serialization-starter" for Kotlin Serialization support.
This will contribute a Json
bean and configure it with the available spring.kotlin.serialization.*
properties.
Note that a HttpMessageConverter
will be also contributed to the application and will be set ahead of other JSON converters (acting as fallbacks).
Support for the newly introduced RestTestClient has been added.
With a regular @SpringBootTest
or when @AutoConfigureMockMvc
is used, you can autowire a RestTestClient
that operates on the underlying MockMvc
instance.
For integration tests, i.e. @SpringBootTest
with either a defined or random port, a RestTestClient
can be injected to target the running server.
Auto-configuration for Static Master/Replica has been added. This feature is only supported by Lettuce.
To use it, provide the list of static nodes using the new spring.data.redis.masterreplica.nodes
property.
The Redis auto-configuration has been improved to auto-configure MicrometerTracing
, rather than MicrometerCommandLatencyRecorder
.
The former operates on the Observation API and provides both metrics and spans.
Spring Boot 4.0 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:
-
Groovy 5.0
-
HikariCP 7.0
-
Jakarta Annotation 3.0
-
Jakarta Servlet 6.1
-
Jakarta WebSocket 2.2
-
Jakarta WS RS 4.0
-
SnakeYAML 2.5
Apart from the changes listed above, there have also been lots of minor tweaks and improvements including:
-
The auto-configuration for Micrometer’s metrics aspects now enables support for
@MeterTag
on@Counted
and@Timed
methods with a SpEL-basedValueExpressionResolver
. -
@ServiceConnection
support for MongoDB now supports Testcontainers'MongoDBAtlasLocalContainer
. -
Improved error message when configuration property binding fails due to a class not found error.
-
Names of several reactive auto-configuration classes have been updated for consistency.
-
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 whenspring.threads.virtual.enabled
istrue
. -
A
logging.console.enabled
property has been introduced. Setting it tofalse
disables console logging. -
Log4j Core configuration file detection for Log4j 3 has been improved.
-
Resource lookup in DevTools restart has been optimized.
-
ScheduledTasksObservabilityAutoConfiguration
has been renamed toScheduledTasksObservationAutoConfiguration
for consistency. -
Authenticating with Elasticsearch using an API key is now supported using the new
spring.elasticsearch.api-key
property. -
ConditionalOnEnabledTracing
has been renamed toConditionalOnEnabledTracingExport
. -
The property
management.tracing.enabled
has been renamed tomanagement.tracing.export.enabled
. -
SanitizableData.getKey()
andSanitizableData.getLowerCaseKey()
never returnnull
. Passing anull
value as akey
in theSanitizableData
will now throw an exception. -
Specialized interfaces have been introduced in
PropertiesConfigAdapter
for better nullability handling. -
The property
spring.dao.exceptiontranslation.enabled
has been renamed tospring.persistence.exceptiontranslation.enabled
. -
The max size of Tomcat’s static cache can now be configured using the
server.tomcat.resource.cache-max-size
property. -
The JSpecify nullability annotations have been refined further.
-
You can now set
Spring-Boot-Jar-Type
todevelopment-tool
in yourMANIFEST.MF
to exclude dependencies from uber jars. -
Amazon Web Services (AWS) Elastic Container Service (ECS) platform is now a recognized
CloudPlatform
. -
Support for Micrometer’s
@ObservationKeyValue
has been added. -
JSpecify nullability annotations have been refined further.
-
Public members from configurations imported by auto-configuration classes have been made package-private.
-
HTML Unit
LocalHostWebClient
andLocalHostWebConnectionHtmlUnitDriver
have been superseded byUriBuilderFactoryWebClient
andUriBuilderFactoryWebConnectionHtmlUnitDriver
. -
A new configuration property can be used to control whether the Elasticsearch Client’s sniffer is enabled.
-
OperationMethod(Method method, OperationType operationType)
in favor ofOperationMethod(Method method, OperationType operationType, Predicate<Parameter> optionalParameters)
. -
Jackson 2 support ships in a deprecated form.
-
org.springframework.boot.env.EnvironmentPostProcessor
has replaced byorg.springframework.boot.EnvironmentPostProcessor
but the old interface remains in a deprecated form to ease upgrade pain.