Spring Boot 4.1 Released: 20 New Features and Key Improvements

Spring Boot 4.1 introduces 20 major updates, including removal of deprecated APIs, new gRPC support, enhanced Jackson configuration, improved observability with OpenTelemetry, SSL for RabbitMQ streams, lazy JDBC connections, and numerous Gradle and Maven plugin enhancements, while providing detailed migration guidance for developers.

Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Spring Boot 4.1 Released: 20 New Features and Key Improvements

Upgrade from Spring Boot 4.0

Deprecated content removed

All classes, methods and properties that were marked deprecated in Spring Boot 4.0 have been eliminated. Users must verify that their code no longer invokes these APIs.

Derby support removed

Apache Derby integration has been dropped because the Derby project is no longer maintained. Projects still using Derby should migrate to H2 or HSQL.

Layered‑tool JAR run mode removed

The layered‑tool JAR run mode has been removed. Users should replace it with an alternative that provides equal or greater capabilities.

Skip tests and AOT handling

The Maven flag -DskipTests is no longer recognized for AOT processing. The Spring Boot Maven plugin now only respects the maven.test.skip property.

Spring Data JPA boot mode

The property spring.data.jpa.repositories.bootstrap-mode has been refined:

Setting the mode to deferred causes an exception when the auto‑configured local container entity‑manager factory cannot find an async task executor bean.

Setting the mode to lazy disables the boot executor entirely, which is appropriate when the executor is not needed.

Reactor client defaults

The default configuration of ReactorClientHttpRequestFactoryBuilder and ReactorClientHttpConnectorBuilder now aligns with the Spring Framework, disabling system‑property proxy configuration.

Customization can be performed with withHttpClientDefaults to modify the defaults, or withoutHttpClientDefaults to remove them entirely.

New Features and Highlights

Spring gRPC support

Spring Boot 4.1 adds first‑class support for developing and testing gRPC servers and clients. Applications can run a Netty‑based standalone gRPC server or expose gRPC over HTTP/2 via a servlet.

Jackson component enhancements

New properties spring.jackson.read.* and spring.jackson.write.* automatically configure Jackson read/write features. The Jackson mapper now includes a processor instantiator that creates handlers from beans in the application context.

Factory‑customizer interfaces are provided: JsonFactoryBuilderCustomizer – customize the JSON factory builder. CborFactoryBuilderCustomizer – customize the CBOR factory builder. XmlFactoryBuilderCustomizer – customize the XML factory builder.

Import configuration file encoding

When using spring.config.import, the file encoding can be specified, e.g.:

spring.config.import=classpath:import.properties[encoding=utf-8]

The default remains ISO‑8859‑1.

HTTP client cookie handling

TestRestTemplate

cookie handling now matches RestTemplate. It can be configured with the new withCookieHandling method or the property spring.http.clients.cookie-handling. The same options are available for RestTemplateBuilder and other HTTP client configuration classes.

Network‑address filter for SSRF protection

Both reactive and blocking HTTP clients can configure a network‑address filter that blocks outbound requests to disallowed addresses, mitigating SSRF attacks.

Observability improvements

Async context propagation with @Async now works across threads.

Automatic observation conventions are applied for Kafka ( KafkaListenerObservationConvention, KafkaTemplateObservationConvention) and RabbitMQ ( RabbitListenerObservationConvention, RabbitTemplateObservationConvention, RabbitStreamListenerObservationConvention, RabbitStreamTemplateObservationConvention).

JVM metric conventions ( JvmMemoryMeterConventions, JvmThreadMeterConventions, JvmClassLoadingMeterConventions, JvmCpuMeterConventions) are auto‑registered.

OpenTelemetry: new properties management.opentelemetry.enabled, management.opentelemetry.tracing.sampler, and limit properties management.opentelemetry.tracing.limits.* and management.opentelemetry.logging.limits.*. The OTLP registry now supports example data and SSL bundling.

OpenTelemetry environment variable support

Most OpenTelemetry environment variables are now mapped to Spring Boot properties.

RabbitMQ stream SSL support

SSL can be enabled with spring.rabbitmq.stream.ssl.enabled=true or by specifying a bundle via spring.rabbitmq.stream.ssl.bundle. The feature works with Testcontainers and Docker Compose.

RabbitMQ stream service connection

Testcontainers example:

private 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;
}

Docker Compose 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]."

Log4j file‑rotation policies

Four rotation modes are supported: size (default) – rotate based on file size. time – rotate based on time interval. size-and-time – rotate when both size and time conditions are met. cron – rotate according to a cron expression.

Embedded LDAP SSL

Embedded LDAP can be configured for LDAPS via spring.ldap.embedded.ssl.bundle.

Simple JMS message listener container

A new configurator for SimpleJmsMessageListener mirrors the existing default JMS listener factory, providing a lightweight option for specific scenarios.

Docker Compose integration

Running docker compose up or docker compose start will, on failure, emit logs from docker compose logs. Log level is controlled by spring.docker.compose.start.log-level (default info).

OAuth2 resource server claim expressions

Authorities can be extracted from JWTs using SpEL expressions via

spring.security.oauth2.resourceserver.jwt.authorities-claim-expressions

. This setting is mutually exclusive with the older claim‑name and delimiter properties. The authority prefix can be customized with spring.security.oauth2.resourceserver.jwt.authority-prefix.

Spring Batch MongoDB integration

Auto‑configuration for Spring Batch with MongoDB is provided, along with the starter spring-boot-batch-data-mongo. Setting spring.batch.data.mongo.schema.initialize=true creates the required collections at startup.

Lazy JDBC connection fetching

The property spring.datasource.connection-fetch accepts eager (default) or lazy. With lazy, the datasource is wrapped in a proxy that obtains a physical connection only when a JDBC statement is executed.

@RedisListener auto‑configuration

Spring Data Redis now auto‑configures a listener container for methods annotated with @RedisListener. Custom containers can be supplied via RedisMessageListenerContainerConfigurer. The starter now depends on spring-messaging.

Application info endpoint enhancements

The info actuator endpoint now includes process details:

process.uptime
process.startTime
process.currentTime
process.timezone
process.locale
process.workingDirectory

Gradle plugin updates

The bootBuildImage task now accepts multiple --environment arguments; command‑line values override script values.

The BuildInfo task writes to META-INF/build-info.properties by default; the filename can be overridden with the filename property.

The DSL method buildInfo has been refined, and the bootBuildInfo task’s output directory is now the main resources folder for better IDE and Gradle handling.

Maven plugin updates

When packaging, custom layer configurations can be placed under META-INF/spring/layers/ as XML files and included as plugin dependencies.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendJavaObservabilitygRPCSpring BootDocker Composespring-boot-4.1spring-boot-features
Spring Full-Stack Practical Cases
Written by

Spring Full-Stack Practical Cases

Full-stack Java development with Vue 2/3 front-end suite; hands-on examples and source code analysis for Spring, Spring Boot 2/3, and Spring Cloud.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.