-
Notifications
You must be signed in to change notification settings - Fork 41.9k
Spring Boot 4.1 Release Notes
Classes, methods and properties that were deprecated in Spring Boot 4.0 have been removed in this release. Please ensure that you aren’t calling deprecated methods before upgrading.
The Apache Derby project team has recently announced that the project has been retired. As a result, the integration in Spring Boot has been deprecated. If you are still using Derby, consider migrating to H2 or HSQL.
The deprecated layertools jar mode has been removed in this release.
If you were still using it, please move to tools that provides the same features (and more).
You can no longer rely on passing -DskipTests to a maven command to skip AOT processing of tests.
The Spring Boot Maven Plugin now only reacts to the maven.test.skip property for consistency with other core plugins.
The spring.data.jpa.repositories.bootstrap-mode property has been refined to better align typical application usage.
-
If you set the mode to
deferred, you will now get an exception if a suitableAsycTaskExecutorbean cannot be found for use with the auto-configuredLocalContainerEntityManagerFactoryBeanbootstrap executor. -
If you set the mode to
lazy, then the auto-configuredLocalContainerEntityManagerFactoryBeanbootstrap executor is no longer set as it’s generally not needed.
Defaults for ReactorClientHttpRequestFactoryBuilder and ReactorClientHttpConnectorBuilder have been updated to align with Spring Framework.
Specifically, proxyWithSystemProperties() is not configured on the underling HttpClient.
If you want different defaults, you can use the withHttpClientDefaults method, or the withoutHttpClientDefaults method to remove defaults entirely.
|
Tip
|
Check the configuration changelog for a complete overview of the changes in configuration. |
Spring Boot 4.1 now provides support for writing and testing gRPC server and client applications. You can write both stand-alone servers (backed by Netty) or use Servlet integration and expose gRPC over HTTP/2.
For details please see the gRPC section of the reference documentation.
|
Note
|
If you a user of Spring gRPC 1.0, the following migration guide will help you upgrade your application to Spring gRPC 1.1 with Spring Boot 4.1. |
General Jackson reading and writing features that are common across multiple formats (CBOR, JSON, and XML) can now be auto-configured using spring.jackson.read. and spring.jackson.write. properties respectively. In addition, auto-configured Jackson mappers are now configured with a HandlerInstantiator that creates handler instances from beans defined in the application context.
Jackson uses factories to create its readers and writers.
These factories can now be configured using various spring.jackson.factory properties to fine tune Jackson’s read and write constraints.
Additionally, for more advanced customization various customizer callbacks are now supported:
-
JsonFactoryBuilderCustomizerfor customization of theJsonFactoryBuilderused by the auto-configuredJsonMapper -
CborFactoryBuilderCustomizerfor customization of theCBORFactoryBuilderused by the auto-configuredCBORMapper -
XmlFactoryBuilderCustomizerfor customization of theXmlFactoryBuilderused by the auto-configuredXmlMapper
When spring.config.import is used, it’s now possible to specify the encoding. In the past, property files always have been loaded with the ISO-8859-1 encoding (which is still the default). To load them using a different encoding, you can use this syntax:
spring.config.import=classpath:import.properties[encoding=utf-8]Cookie handling with TestRestTemplate has been updated to align with RestTemplate.
The new withCookieHandling method can be used to configure the handling as required.
Similar to TestRestTemplate, RestTemplateBuilder and HttpClientSettings also now allow cookie handling to be configured.
When using an auto-configured HTTP client, cookie handling can be configured using the new spring.http.clients.cookie-handling configuration property.
Both reactive and blocking HTTP clients can now be configured with an InetAddressFilter which can block outgoing requests to specific addresses.
This feature is useful for hardening your applications against SSRF attacks.
For more details on how to use the InetAddressFilter please see the updated reference documentation.
Context can be automatically propagated to methods running on a separate thread using @Async.
See the Reference Guide for more details.
A number of improvements have been made to support for observation conventions:
-
KafkaListenerObservationConventionbeans are now automatically applied to the Kafka container factory. -
KafkaTemplateObservationConventionbeans are now automatically applied to theKafkaTemplate -
RabbitListenerObservationConvention,RabbitTemplateObservationConvention,RabbitStreamListenerObservationConventionandRabbitStreamTemplateObservationConventionbeans are now automatically configured on the Spring AMQP components
Improvements to meter conventions have also been made:
-
Any
JvmMemoryMeterConventionsbean is applied to the auto-configuredJvmMemoryMetrics -
Any
JvmThreadMeterConventionsbean is applied to the auto-configuredJvmThreadMetrics -
Any
JvmClassLoadingMeterConventionsbean is applied to the auto-configuredClassLoaderMetrics -
Any
JvmCpuMeterConventionsbean is applied to the auto-configuredProcessorMetrics
The new property management.opentelemetry.enabled can be used to disable the OpenTelemetry SDK.
It then uses no-op implementations for the SdkTracerProvider,
SdkLoggerProvider and SdkMeterProvider, but still configures the propagators.
Additionally, it doesn’t create the tracing and logging beans which would be superfluous for a disabled SDK.
Properties have been added to configure OpenTelemetry’s BatchLogRecordProcessor, similar to the properties for BatchSpanProcessor.
A new property management.opentelemetry.tracing.sampler has been added for configuring OpenTelemetry’s sampler.
There’s also auto-configuration for SpanLimits and LogLimits, with properties under management.opentelemetry.tracing.limits. and management.opentelemetry.logging.limits. to configure them.
Support for OTLP exemplars has been added to Micrometer’s OtlpRegistry.
This will automatically be configured if you’re using metrics over OTLP and Micrometer Tracing.
SSL bundle support has been added to OTLP logging, metrics and trace exporters.
Support has been added to read most of the OpenTelemetry environment variables (for example those, those, and those).
A complete list of all supported variables and their corresponding Spring Boot configuration property can be found in the documentation.
Auto-configuration of SSL is now supported when using RabbitMQ Streams.
To enable the support, set spring.rabbitmq.stream.ssl.enabled to true or use spring.rabbitmq.stream.ssl.bundle to configure the SSL bundle to use.
SSL is also supported when using RabbitMQ Streams with Docker Compose or Testcontainers.
Service connections to RabbitMQ Streams are now supported with both Testcontainers and Docker Compose.
When using Testcontainers, a service connection can be made using @ServiceConnection(type = RabbitStreamConnectionDetails.class).
The rabbitmq_stream plugin must also be enabled in the container as shown in the following example:
private static RabbitMQContainer createRabbitMqStreamContainer() {
RabbitMQContainer container = TestImage.container(RabbitMQContainer.class);
container.addExposedPorts(RABBITMQ_STREAMS_PORT);
String enabledPlugins = "[rabbitmq_stream].";
container.withCopyToContainer(Transferable.of(enabledPlugins), "/etc/rabbitmq/enabled_plugins");
return container;
}When using Docker Compose, the RabbitMQ service must map container port 5552.
As with Testcontainers, the rabbitmq_stream plugin must also be enabled as shown in the following example:
services:
rabbitmq:
image: '{imageName}'
environment:
- 'RABBITMQ_DEFAULT_USER=myuser'
- 'RABBITMQ_DEFAULT_PASS=secret'
configs:
- source: plugins
target: /etc/rabbitmq/enabled_plugins
ports:
- '5552'
configs:
plugins:
content: "[rabbitmq_stream]."Support for configurable file rotation has been added for Log4j, with four strategies:
-
size (default): Rolls files based on their size.
-
time: Rolls files based on a time interval.
-
size-and-time: Rolls when both size and time conditions are met.
-
cron: Rolls based on a cron expression schedule.
Auto-configuration of an embedded LDAP server now supports SSL (LDAPS).
To enable SSL, configure an SSL bundle using the spring.ldap.embedded.ssl.bundle property.
The JMS support has been improved to provide a configurer for SimpleJmsMessageListener that is similar to the existing DefaultJmsListenerContainerFactoryConfigurer.
The simple implementation may be more suitable in certain scenarios, check the Spring Framework Reference Guide for more details.
In the event of a failure when it calls docker compose up or docker compose start, Spring Boot’s Docker Compose support will now log the output of docker compose logs.
The log message is output at the level specified by spring.docker.compose.start.log-level.
It defaults to info.
Auto-configuration is now provided for extracting authorities from a JWT using one or more SpEL expressions.
To enable the support, set the spring.security.oauth2.resourceserver.jwt.authorities-claim-expressions property.
It is supported in both Servlet and Reactive applications and is mutually exclusive with the existing
spring.security.oauth2.resourceserver.jwt.authorities-claim-name and spring.security.oauth2.resourceserver.jwt.authorities-claim-delimiter properties.
Set spring.security.oauth2.resourceserver.jwt.authority-prefix if the resulting authorities should have a prefix other than the SCOPE_ default.
Auto-configuration for Spring Batch using MongoDB is provided, alongside a new spring-boot-batch-data-mongo starter.
The schema required to run Spring Batch jobs can be created automatically on startup by settings the spring.batch.data.mongo.schema.initialize property to true.
By default, the default schema is applied but a custom newline-delimited JSON script can be provided.
Added a new spring.datasource.connection-fetch property (eager, lazy).
When set to lazy, the auto-configured pooled DataSource is wrapped with LazyConnectionDataSourceProxy so a physical connection is taken from the pool only when a JDBC statement is actually needed.
Add auto-configure for Spring Data Redis’s @RedisListener endpoints.
If the application does not define a RedisMessageListenerContainer, a default container is registered so listener methods can be discovered and invoked without extra wiring.
See spring.data.redis.listener.* for a list of options.
Applications that need additional containers can use RedisMessageListenerContainerConfigurer to apply the same defaults as auto-configuration when building their own RedisMessageListenerContainer beans.
The spring-boot-starter-data-redis starter now also declares a dependency on spring-messaging, which is required by this feature.
The info endpoint now provides additional information about the process. The following fields are now available in the endpoint’s response:
-
process.uptime -
process.startTime -
process.currentTime -
process.timezone -
process.locale -
process.workingDirectory
Refer to the endpoint’s API documentation for further details.
The Gradle plugin’s bootBuildImage task now supports specifying environment variables on the command line using --environment.
To specify multiple environment variables, use --environment multiple times.
If an environment variable is configured both on the command line and in a build script, the value of the command line takes precedence.
By default, the BuildInfo Gradle task now produces a file named META-INF/build-info.properties in its configured destination directory.
Previously, the file was named build-info.properties.
The new filename property can be used to customize the name and, if required, restore the previous name.
The buildInfo methods on the Spring Boot DSL have been updated to improve the configuration of task inter-dependencies.
The destination directory of the bootBuildInfo task is now configured as a source directory of the main source set’s resources.
This improves the visibility of the generated file in IDEs that do not delegate to Gradle.
It also provides Gradle with better information about the tasks' interdependencies and the relationship between their inputs and outputs.
It is now possible to load the layers configuration that the Maven plugin should use to repackage the application.
Custom layers should be placed in META-INF/spring/layers/<name>.xml and added as a plugin’s dependency.
Review the documentation for more details.
This release reintroduces Spock support since we now have a Spock 2.4 release that support Groovy 5.
Spring Boot 4.1.0 moves to new versions of several Spring projects:
Numerous third-party dependencies have been updated, some of the more noteworthy of which are the following:
-
Commons Pool2 2.13.1
-
HttpClient5 5.6.1
-
HttpCore5 5.4.2
-
Oracle Database 23.26.2.0.0
-
Pooled JMS 3.2.2
-
SnakeYAML 2.6
Apart from the changes listed above, there have also been lots of minor tweaks and improvements including:
-
The web servers' temporary directories are now deleted when the context is closed.
-
Additional mime types that should be compressed when sending HTTP responses can be configured using
server.compression.additional-mime-types -
Application-wide HTML escaping configuration for webflux can be configured using
spring.webflux.default-html-escape. -
Value objects now bind
Optionalparameters asOptional.empty()rather thannull. This applies to any@ConfigurationPropertiesthat use constructor binding. -
Empty objects in YAML files are now retained in the resulting
PropertySource. -
It’s now possible to bind default properties when an empty property is defined (see the updated documentation for details)
-
EntityManagerFactoryBuildercan now addPersistenceUnitPostProcessorinstances rather than just setting them. -
A new
FailureAnalyzedExceptionhas been added and can be used when you want to throw an exception that include its own failure analysis. -
Auto-configuration for Spring Data REST supports a new
spring.data.rest.return-body-on-deleteproperty. -
Mustache support consistently uses
Charsetinstead of theStringequivalent. -
Customizers for
OtlpHttpLogRecordExporterBuilderandOtlpGrpcLogRecordExporterBuilderhave been added. -
Kotlin extensions for
TestEntityManagerhave been added. -
OAuth2 resource servers can now be configured in non-webapps.
-
A new
spring.jpa.bootstrapproperty has been added to allow you to configure async background bootstrapping of theLocalContainerEntityManagerFactoryBean. -
Console ANSI support is now enabled by default on Microsoft Windows 11 and later.
-
Add support for configuring
closeTimeoutandallowNonTransactionalonKafkaTemplate. -
Docker Compose support has been added for
docker.elastic.co/elasticsearch/elasticsearch. -
The actuator info endpoint now also returns certificates from the truststore.
-
Compression can now be used when exporting metrics over OTLP. To enable compression set
management.otlp.metrics.export.compression-modetogzip. -
publishMaxGaugeForHistogramscan be configured on theOTLPRegistry. -
The property
management.tracing.exemplars.filtercan be used to exercise more fine-grained support for selecting metric exemplars. -
Expiry times from certificates in the truststore are now also available as metrics.
-
AssertJ
Assertimplementations now make use of@CheckReturnValuewhen applicable. -
A new failure analyzer now provides more details when Testcontainers cannot find a suitable Docker environment.
-
Beans defined by
MockRestServiceServiceAutoConfigurationare now@ConditionalOnMissingBean, making them easier to replace if needed. -
A new
@AutoConfigureWebServertest annotation has been added allowing you to add the embedded web server factory bean for tests to use.
-
org.springframework.boot.jdbc.DatabaseDriver.DERBYandorg.springframework.boot.jdbc.EmbeddedDatabaseConnection.DERBY -
Properties and classes for configuring the Dynatrace V1 API, in favor of using the V2 API
-
Given its decrease in popularity and support, the LiveReload feature in Devtools is deprecated with no replacement.