What’s New in Spring Boot 3.1? Key Features and Upgrades Explained

Spring Boot 3.1.0 introduces a host of enhancements—including automatic configuration for Spring Authorization Server, upgraded HttpClient support, refined Testcontainers integration, new Docker‑Compose capabilities, and updates to Hibernate, Jackson, Mockito, and SSL handling—while also providing detailed Maven and Gradle options for image building.

Programmer DD
Programmer DD
Programmer DD
What’s New in Spring Boot 3.1? Key Features and Upgrades Explained

Spring Boot 3.1.0 has been released, adding a large number of new features and improvements.

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>3.1.0</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>

Highlights

Automatic configuration for Spring Authorization Server

Support for managing external services with Testcontainers and Docker Compose during development

Simplified Testcontainers configuration for integration tests

Support for Mockito unit testing

Upgrade to HttpClient 5

Spring Framework 6 recommends using Apache HttpClient 5 and has removed support for HttpClient 4 and RestTemplate. Spring Boot 3.0 managed dependencies for both versions, but using HttpClient 4 can still cause hard‑to‑diagnose errors with RestTemplate. Spring Boot 3.1 removes the dependency management for HttpClient 4 to encourage migration to HttpClient 5.

Servlet and Filter Registration Optimization

If registration of ServletRegistrationBean or FilterRegistrationBean fails, an IllegalStateException is now thrown instead of merely logging a warning. To retain the previous behavior, call setIgnoreRegistrationFailure(true) on the bean.

Git Commit ID Maven Plugin Version Property

The property that overrides the version of io.github.git-commit-id:git-commit-id-maven-plugin has been updated to match its artifact name. Replace git-commit-id-plugin.version with git-commit-id-maven-plugin.version in pom.xml.

Spring Kafka Retry Topic Auto‑Configuration

When spring.kafka.retry.topic.enabled=true and exponential back‑off with a maximum delay is used, all retry attempts now go to the same topic, whereas previously each delay level created a separate topic.

Testcontainers Dependency Management

Spring Boot now manages Testcontainers dependencies. The version can be overridden with the testcontainers.version property if needed.

Hibernate 6.2

Spring Boot 3.1 upgrades to Hibernate 6.2. See the Hibernate 6.2 migration guide for impact details.

Jackson 2.15

Spring Boot 3.1 upgrades to Jackson 2.15. Notable changes include new stream‑read constraints. Adjust them by defining a Jackson2ObjectMapperBuilderCustomizer such as:

@Bean
Jackson2ObjectMapperBuilderCustomizer customStreamReadConstraints() {
    return builder -> builder.postConfigurer(objectMapper ->
        objectMapper.getFactory()
            .setStreamReadConstraints(
                StreamReadConstraints.builder()
                    .maxNestingDepth(2000)
                    .build()));
}

Upgrade Mockito 5

Spring Boot 3.1 upgrades to Mockito 5 (specifically 5.3). Refer to the Mockito release notes for major changes.

Health Groups Default Validation

Health group member configurations are now validated at startup. If a health indicator that is included or excluded does not exist, the application fails to start. Set management.endpoint.health.validate-group-membership=false to disable this validation and revert to earlier behavior.

Service Connections

A new concept of service connections is introduced via ConnectionDetails beans, which provide the necessary details for establishing remote service connections. Spring Boot’s auto‑configuration now consumes these beans, giving them precedence over related configuration properties.

Docker Compose Integration

The new module spring-boot-docker-compose integrates Docker Compose. At startup, it looks for configuration files in the current working directory, supporting compose.yaml, compose.yml, docker-compose.yaml, and docker-compose.yml. Non‑standard file names can be specified with spring.docker.compose.file. Declared services are started with docker-compose up and stopped with docker-compose down when the application shuts down. Lifecycle management can be customized via properties such as spring.docker.compose.lifecycle-management, spring.docker.compose.startup.command, and spring.docker.compose.shutdown.command.

SSL Configuration

SSL trust material (Java KeyStores, PEM‑encoded certificates) can now be configured via properties and applied consistently across embedded web servers, data services, RestTemplate, and WebClient. See the reference documentation for details.

Spring Authorization Server Auto‑Configuration

This release adds support for the Spring Authorization Server project and introduces the starter spring-boot-starter-oauth2-authorization-server. See the Authorization Server section of the Spring Boot reference documentation for more information.

Docker Image Build Enhancements

The spring-boot:build-image Maven goal and bootBuildImage Gradle task now support a createdDate option to set the image’s Created metadata field to a user‑specified date or now. They also support an applicationDirectory option to control where application content is uploaded inside the builder image before the build pack consumes it.

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.

JavaBackend DevelopmentSpring BootJacksonDocker ComposeHibernateRelease NotesTestcontainers
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

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.