Executive Summary
1 min summary
Upgrading from Spring Boot 3 to Spring Boot 4 introduces a new class of silent runtime regressions that pass compilation and start cleanly without warnings. Because Spring Boot 4 splits the monolithic spring-boot-autoconfigure JAR into fine-grained technology modules, restructures SecurityAutoConfiguration into three separate classes, and moves slice test support into dedicated test starters, valid application.yml properties can quietly stop taking effect while services fall back to unsafe defaults. Engineering teams can prevent production surprises by diffing /actuator/conditions snapshots between Boot 3 and Boot 4 builds, replacing legacy exclusions with verified bean contracts, and treating spring-boot-autoconfigure-classic strictly as a temporary bridge.
The pull request turns green on a Thursday afternoon. All 400 compilation errors from the Spring Boot 4 upgrade are gone. Imports point to the new packages, Jackson 3 builds cleanly, and the test suite passes. You deploy to staging, watch the banner scroll past with zero warnings, and call the migration done.
Two days later under peak load, p99 latency doubles, Kubernetes restarts pods with OutOfMemoryError, and your Kafka consumer lag climbs linearly. Nothing crashed at startup. Nothing logged an ERROR.
Every Spring Boot 4 migration guide covers the loud breaks: relocated packages, Jackson 3, JSpecify nullness annotations, removed deprecations. Those breaks are polite because the compiler stops you before anything ships. The expensive regressions in a Spring Boot 3-to-4 cutover never fail compilation. They exploit the structural gap between property binding and @Conditional evaluation (explored in False Scent), amplified by Spring Boot 4’s biggest architectural change: modularized auto-configuration.
Why a Green Build Is Only Half the Migration
In Spring Boot 3.x, nearly every built-in auto-configuration lived inside one monolithic spring-boot-autoconfigure JAR. If your service pulled in a raw library such as spring-kafka, caffeine, or a Redis client (often transitively through an internal platform library), the matching @AutoConfiguration class was already sitting on the classpath waiting to match @ConditionalOnClass.
Spring Boot 4.0 broke that monolith into focused technology modules (spring-boot-jdbc, spring-boot-cache, spring-boot-kafka, spring-boot-security, spring-boot-rsocket) and moved classes from org.springframework.boot.autoconfigure.<tech> into org.springframework.boot.<tech>.autoconfigure.
That cleanup gives Spring Boot a much cleaner dependency graph, but it introduces a failure mode that barely existed in Boot 3: the raw library without its Boot 4 module.
If a service depends on org.springframework.kafka:spring-kafka or com.github.ben-manes.caffeine:caffeine without pulling in the matching Spring Boot 4 starter (spring-boot-starter-kafka, spring-boot-starter-cache), the project still compiles. Your application.yml still binds or sits quietly in the Environment. Yet the @AutoConfiguration class is never even present on the classpath to evaluate. When you inspect the condition report, it does not appear in Positive matches or Negative matches. It simply vanished from the trail.
What to check: Search your
build.gradle.ktsorpom.xmlfiles for direct dependencies on raw Spring or infrastructure libraries (spring-kafka,hikaricp,caffeine,spring-data-redis) that rely on transitive auto-configuration. In Spring Boot 4, every one of them needs its matching Boot 4 starter or auto-configuration module.
Migration Trap 1: The SecurityAutoConfiguration Split and Dead exclude Lists
Few annotations get carried across Spring Boot upgrades as routinely as:
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
or its YAML twin in application-test.yml:
spring:
autoconfigure:
exclude:
- org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
In Spring Boot 3.x, excluding org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration disabled default web security wiring in one line.
In Spring Boot 4.0, that class was relocated and split into three distinct auto-configurations:
org.springframework.boot.security.autoconfigure.SecurityAutoConfiguration(registersSecurityPropertiesand security event publishing)org.springframework.boot.security.autoconfigure.UserDetailsServiceAutoConfiguration(registersinMemoryUserDetailsManager)org.springframework.boot.security.autoconfigure.web.servlet.ServletWebSecurityAutoConfiguration(wires the default servletSecurityFilterChain)
Verified directly against Spring Boot 4.0.10, carrying over a Boot 3 exclusion pattern produces two distinct failure modes:
- Failure Mode A (startup crash): If you update the import to Boot 4’s
SecurityAutoConfigurationand exclude only that class whileUserDetailsServiceAutoConfigurationremains active, startup fails withUnsatisfiedDependencyExceptiononinMemoryUserDetailsManagercaused byNoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.security.autoconfigure.SecurityProperties' available. - Failure Mode B (unexpectedly active filter chain): If you also exclude
UserDetailsServiceAutoConfiguration(or supply a customUserDetailsService),ServletWebSecurityAutoConfigurationstill matches and wires the defaultSecurityFilterChain.
String-based ordering hooks carry a quieter version of the same bug. Any internal starter using @AutoConfigureBefore(name = ...) or @AutoConfigureAfter(name = ...) with an old Boot 3 package string compiles cleanly and silently becomes a no-op once the target class moves.
And remember the sibling trap from Part 1: shared internal security starters annotated with @ConditionalOnWebApplication(type = Type.SERVLET) silently skip inside reactive WebFlux services, leaving zero SecurityFilterChain beans behind. Never assume a security migration succeeded because an endpoint returned 200. Assert the active SecurityFilterChain or SecurityWebFilterChain bean explicitly.
Once your security exclusions compile and boot, the natural next move is running your web and persistence slice tests to verify behavior. That is where modularization bites a second time.
Migration Trap 2: Slice Tests Losing Auto-Configuration (and the classic Crutch)
Modularization hit spring-boot-test-autoconfigure just as hard. In Spring Boot 3.x, adding spring-boot-starter-test brought in test auto-configuration for every slice (@WebMvcTest, @JdbcTest, @AutoConfigureCache, @WebFluxTest).
In Spring Boot 4.0, slice tests require dedicated modular test starters:
spring-boot-starter-webmvc-testspring-boot-starter-jdbc-testspring-boot-starter-cache-testspring-boot-starter-security-testspring-boot-starter-kafka-test
When teams upgrade spring-boot-starter-test without adding the matching *-test starters, slice tests either fail to resolve annotations or boot a stripped context missing the auto-configuration under test.
Spring Boot 4 provides compatibility bridges (spring-boot-starter-classic, spring-boot-autoconfigure-classic, and spring-boot-starter-test-classic) that pull the old monolithic auto-configuration and test-slice sets back onto the classpath. Those bridges are useful during week one of a large upgrade when you want to get a multi-module build compiling first.
The trap is leaving classic in place. While spring-boot-autoconfigure-classic or spring-boot-starter-test-classic sits in your build, every missing modular starter stays hidden. Your service looks migrated on paper, yet the day someone removes the compatibility module six months later, half a dozen auto-configurations silently drop out at once. Treat classic as scaffolding with a hard removal ticket attached to the same milestone, not a permanent dependency.
Even after every Boot 4 starter and *-test module is wired properly, one more category of silent regression survives intact: custom beans carried forward from Boot 2 and Boot 3.
Migration Trap 3: Silent Loss of Kafka Virtual Threads and public final Auto-Configs
In Spring Boot 4.0, org.springframework.boot.kafka.autoconfigure.KafkaAnnotationDrivenConfiguration wires spring.kafka.listener.* settings inside ConcurrentKafkaListenerContainerFactoryConfigurer. That same configurer attaches Java 21 Virtual Threads (SimpleAsyncTaskExecutor via @ConditionalOnThreading(Threading.VIRTUAL)) whenever spring.threads.virtual.enabled=true.
Look at what happens when a service defines its own kafkaListenerContainerFactory bean without injecting that configurer, a pattern still widespread in older Boot 2 and Boot 3 codebases:
@Bean
fun kafkaListenerContainerFactory(
consumerFactory: ConsumerFactory<Any, Any>,
): ConcurrentKafkaListenerContainerFactory<Any, Any> =
ConcurrentKafkaListenerContainerFactory<Any, Any>().apply {
setConsumerFactory(consumerFactory)
}
In Spring Boot 4.0.10, KafkaProperties still binds spring.kafka.listener.concurrency=4 cleanly. Meanwhile, KafkaAnnotationDrivenConfiguration#kafkaListenerContainerFactory quietly backs off on @ConditionalOnMissingBean(name = "kafkaListenerContainerFactory"). The live container factory runs with concurrency = null (a single consumer thread) and listenerTaskExecutor = null (falling back to platform threads instead of Virtual Threads).
The deterministic fix is either registering a ContainerCustomizer instead of replacing the factory bean, or injecting ConcurrentKafkaListenerContainerFactoryConfigurer explicitly:
@Bean
fun kafkaListenerContainerFactory(
configurer: ConcurrentKafkaListenerContainerFactoryConfigurer,
consumerFactory: ConsumerFactory<Any, Any>,
): ConcurrentKafkaListenerContainerFactory<Any, Any> =
ConcurrentKafkaListenerContainerFactory<Any, Any>().also { factory ->
configurer.configure(factory, consumerFactory)
}
One more Boot 4 structural break during migration: top-level auto-configuration classes (including RSocketServerAutoConfiguration, KafkaAutoConfiguration, and CacheAutoConfiguration) are now public final, with non-public factory methods. Any Boot 3 workaround that subclassed an auto-configuration or relied on CGLIB proxying will fail outright. Replace those hacks with Customizer beans, or mark auxiliary infrastructure beans @Bean(defaultCandidate = false) so secondary DataSource beans no longer silence DataSourceConfiguration.Hikari.
Key Spring Boot 3-to-4 Auto-Configuration Relocation Map
Before you compare runtime condition reports across versions, you need to separate harmless package moves from genuinely lost auto-configurations. Here are the high-blast-radius relocations teams hit most often (the full 60-entry registry lives in Boot3To4PackageMap.kt inside the companion BootTruth repository):
| Subsystem | Spring Boot 3.x Package Prefix | Spring Boot 4.0 Package Prefix | Required Boot 4 Starter |
|---|---|---|---|
| JDBC & Hikari | org.springframework.boot.autoconfigure.jdbc. | org.springframework.boot.jdbc.autoconfigure. | spring-boot-starter-jdbc |
| Hibernate / JPA | org.springframework.boot.autoconfigure.orm.jpa. | org.springframework.boot.hibernate.autoconfigure. | spring-boot-starter-data-jpa |
| Caching | org.springframework.boot.autoconfigure.cache. | org.springframework.boot.cache.autoconfigure. | spring-boot-starter-cache |
| Redis | org.springframework.boot.autoconfigure.data.redis. | org.springframework.boot.data.redis.autoconfigure. | spring-boot-starter-data-redis |
| Kafka | org.springframework.boot.autoconfigure.kafka. | org.springframework.boot.kafka.autoconfigure. | spring-boot-starter-kafka |
| RSocket | org.springframework.boot.autoconfigure.rsocket. | org.springframework.boot.rsocket.autoconfigure. | spring-boot-starter-rsocket |
| Security (split) | org.springframework.boot.autoconfigure.security. | org.springframework.boot.security.autoconfigure. | spring-boot-starter-security |
| Servlet MVC | org.springframework.boot.autoconfigure.web.servlet. | org.springframework.boot.webmvc.autoconfigure. | spring-boot-starter-webmvc |
| WebFlux | org.springframework.boot.autoconfigure.web.reactive. | org.springframework.boot.webflux.autoconfigure. | spring-boot-starter-webflux |
| RestClient | org.springframework.boot.autoconfigure.web.client. | org.springframework.boot.restclient.autoconfigure. | spring-boot-starter-restclient |
| Jackson | org.springframework.boot.autoconfigure.jackson. | org.springframework.boot.jackson.autoconfigure. | spring-boot-starter-json |
| Metrics / Tracing | org.springframework.boot.actuate.autoconfigure.metrics. | org.springframework.boot.micrometer.metrics.autoconfigure. | spring-boot-starter-actuator |
The Practical Cutover Playbook: Before / After Condition Diff
A blind grep through build.gradle.kts will still miss transitive auto-configurations that changed behavior between Boot 3 and Boot 4. The fastest way to prove nothing silently turned off is to diff the live ConditionEvaluationReport before and after the upgrade.
Step 1: Capture the Spring Boot 3 Baseline Snapshot
Before touching your Spring Boot version, boot the service with your staging profile (or an integration test profile matching production flags) and capture /actuator/conditions:
curl -sS http://localhost:8081/actuator/conditions > baseline-boot3.json
Step 2: Upgrade to Spring Boot 4 and Capture the Target Snapshot
Once the service compiles and starts on Spring Boot 4 (with spring-boot-autoconfigure-classic removed), capture the matching endpoint:
curl -sS http://localhost:8081/actuator/conditions > target-boot4.json
Step 3: Diff Positive Matches, Negative Matches, Disappeared Classes, and Split Warnings
A raw diff or jq comparison is noisy because every moved package looks deleted and re-added. Normalize Boot 3 prefixes to their Boot 4 equivalents first, then inspect four buckets:
- Positive to Negative regressions: An auto-configuration that matched in Boot 3 now backs off in Boot 4 (for example,
CaffeineCacheConfigurationorKafkaAnnotationDrivenConfiguration#kafkaListenerContainerFactory). - Disappeared auto-configurations: Present in Boot 3
positiveMatches, completely absent from Boot 4’s report. This is the unmistakable fingerprint of a missing Boot 4 modular starter JAR. - Boot 4 split class warnings: An exclusion carried over from Boot 3 (such as
SecurityAutoConfiguration) while one of its Boot 4 replacements (ServletWebSecurityAutoConfiguration) remains active. - Negative to Positive activations: An unexpected fallback just woke up (such as
SimpleCacheConfigurationtaking over for Caffeine).
Using the standalone boot-truth-diff CLI, the reusable GitHub Action (grupavii/boot-truth/.github/actions/boot-truth-diff), or the native Gradle (eu.grupavii.boottruth.diff -> bootTruthDiff) and Maven (boot-truth-maven-plugin -> mvn boot-truth:diff) plugins from the open-source companion repository github.com/grupavii/boot-truth, that entire check runs as one CI command:
./gradlew :boot-truth-diff:run --args="samples/baseline-boot3.json samples/target-boot4.json --format markdown --fail-on-regression"
Because boot-truth-diff canonicalizes all 60 Boot 3-to-4 package prefixes automatically, benign relocations (DataSourceConfiguration$Hikari, WebMvcAutoConfiguration) stay silent while real cutover drift renders straight into a PR comment:
## BootTruth Conditions Diff - `DRIFT DETECTED`
| Category | Count |
|---|---|
| Regressions (Positive -> Negative) | **1** |
| Disappeared Auto-Configurations | **1** |
| Boot 4 Split Class Warnings | **1** |
| Newly Activated (Negative -> Positive) | 1 |
| Newly Added | 0 |
### Regressions (Positive -> Negative)
- **`CaffeineCacheConfiguration`**: @ConditionalOnClass did not find 'Caffeine'
### Disappeared Auto-Configurations (Check Boot 4 Modular Starters)
- **`KafkaAutoConfiguration`**: absent in target (verify: spring-boot-starter-kafka)
### Boot 4 Split Class Warnings (Review Exclusions & Replacements)
- **`SecurityAutoConfiguration`**: exclusion detected while ServletWebSecurityAutoConfiguration remained active
Step 4: Verify Live Bean Types and Applied Values
Finally, confirm the five runtime beans with the highest production blast radius:
CacheManageris notConcurrentMapCacheManager(andspring.cache.typeis pinned explicitly).- Primary
DataSourceisHikariDataSourcewith your actual YAMLmaximumPoolSizeandconnectionTimeoutapplied. SecurityFilterChainorSecurityWebFilterChainis present and matches your intended Servlet or WebFlux stack.kafkaListenerContainerFactoryhas your configuredconcurrencyandSimpleAsyncTaskExecutor(ifspring.threads.virtual.enabled=true).- Transport customizers (like
RSocketServerCustomizerover WebFlux WebSockets, from The Trail That Went Cold) are registered when YAML properties do not bind to embedded server paths.
Rule of thumb: Never sign off a Spring Boot 3-to-4 upgrade on a green build alone. Sign off on a clean
/actuator/conditionsdiff and five runtime bean assertions.
Honest Trade-Offs of Condition Diffing
Diffing /actuator/conditions is high-leverage, but it has two real edges you should account for:
- Parse-phase ghost matches in Boot 4’s report: As noted in Part 1, nested
@Import-ed classes likeDataSourceConfiguration$Hikarican remain inpositiveMatcheseven when their importing parent backs off and registers zero beans (we fix this at theBeanFactorylevel in Part 3). That is why Step 4 — verifying live bean instances — remains mandatory alongside the JSON diff. - Noisy diffs during big-bang upgrades: If you upgrade Spring Boot, Hibernate, Kafka, and internal platform starters in a single giant PR, your condition diff will contain dozens of expected changes mixed with real regressions. Keep the Boot 3-to-4 cutover isolated from feature refactors so every line in the condition diff has a clear explanation.
What Engineering Leaders Should Mandate Before Cutover
For CTOs and VPs of Engineering scheduling a Spring Boot 4 upgrade across ten or fifty services, the economics are stark. Running a before-and-after /actuator/conditions diff and adding a 40-line infrastructure contract test takes roughly two hours per service template. Hunting down a silent ConcurrentMapCacheManager OOM, a reverted 10-connection Hikari pool, or a dropped Kafka virtual-thread executor in production after a cutover routinely costs two weeks of senior engineering time and an avoidable customer incident.
Require three concrete gates on every service before production cutover:
- Mandatory
/actuator/conditionsdiff: No Spring Boot 3-to-4 upgrade PR merges without a clean baseline-versus-target condition diff showing zero unexplained regressions, disappeared starters, or split-class warnings. - No permanent
classiccrutches: Allowspring-boot-autoconfigure-classiconly on short-lived migration branches, with a CI check blocking it onmainbefore release. - Live runtime contract tests: Verify actual
CacheManager,HikariDataSource, security chain, and Kafka listener factory beans without@MockitoBeanoverrides.
In Part 3 of this series, we turn those one-off migration gates into permanent 50-millisecond CI guardrails so silent @Conditional drift cannot creep back in on future feature branches.
Do that before you merge that green Thursday afternoon pull request, and Saturday’s peak load stays boring. Good trackers do not judge a crossing by how quiet the woods look. They check every footprint on the far bank before bringing the rest of the pack across.
Planning a Spring Boot 4 upgrade across business-critical JVM services? A fixed-scope 2-Week Architecture Review audits your auto-configuration contracts, dependency boundaries, and legacy modernization cutover risks before they hit production, or send one upgrade bottleneck through the contact form for three candid observations within 48 hours.