Spring Boot 3.4 Upgrade Guide: Major Changes and Features
Spring Boot 3.4 adds automatic multi‑client RestClient configuration, Bean‑Validation‑based property checks, default graceful shutdown, ECS/GELF/Logstash structured logging, enhanced observability with application grouping and OTLP tracing, upgraded core and third‑party dependencies, AssertJ‑enabled MockMvc testing, and replaces old management endpoint settings with access‑based properties.
Spring Boot 3.4 introduces significant performance improvements, enhanced observability, and better developer experience. This guide outlines the most important changes and provides code examples to help with migration.
1. RestClient and RestTemplate – Automatic configuration now supports multiple HTTP clients (Apache HttpComponents, Jetty, Reactor Netty, JDK HttpClient). The client priority order is listed. Example configuration:
# 1. Use http-components
spring.http.client.factory=http-components
# 2. Use jetty
spring.http.client.factory=jetty
# 3. Disable redirects
spring.http.client.redirects=dont-follow2. Bean Validation for Configuration Properties – Validation follows the Bean Validation spec and only validates nested properties annotated with @Valid. Example before/after:
@ConfigurationProperties(prefix = "pig")
@Validated
public class GatewayConfigProperties {
private SwaggerProperties swagger;
} @ConfigurationProperties(prefix = "pig")
@Validated
public class GatewayConfigProperties {
@Valid // added
private SwaggerProperties swagger;
}3. Graceful Shutdown – All embedded web servers (Jetty, Reactor Netty, Tomcat, Undertow) enable graceful shutdown by default. To disable:
server.shutdown=immediate4. Structured Logging – Supports ECS, GELF, and Logstash formats. Example ECS JSON:
{
"@timestamp":"2024-01-01T10:15:00.067462556Z",
"log.level":"INFO",
"process.pid":39599,
"service.name":"simple",
"message":"No active profile set, falling back to 1 default profile: \"default\"",
"ecs.version":"8.11"
}Configuration to enable ECS format for file and console:
# File output uses ECS format
logging.structured.format.file=ecs
# Console output uses ECS format
logging.structured.format.console=ecs5. Observability Improvements – Application grouping and OTLP tracing settings:
# Set application group
spring.application.group=order-processing
# Include group in logs
logging.include-application.group=true
# Enable gRPC transport for OTLP
management.otlp.tracing.transport=grpc
management.otlp.tracing.endpoint=grpc://otel-collector:43176. Dependency Version Upgrades – Core Spring framework components upgraded (Spring Framework 6.2, Spring Data 2024.1, Spring Security 6.4, Spring Batch 5.2) and third‑party libraries (Hibernate 6.6, Jackson 2.18.0, Micrometer 1.14, Reactor 2024.0, Testcontainers 1.20.3).
7. Testing Enhancements – MockMvc now supports AssertJ assertions:
@Autowired
private MockMvcTester mockMvcTester;
@Test
void testEndpoint() throws Exception {
mockMvcTester.get("/api/data")
.andExpect(status().isOk())
.andExpect(jsonPath("$.name").value("Sample Data"));
}8. Deprecated Features – Example of old management endpoint properties replaced with new access‑based settings.
management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=true management.endpoints.access.default=none
management.endpoint.health.access=read-onlyJava Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.