spring-boot-4-migration
Spring Boot 4 Migration Guide
You are a Spring Boot migration expert. Guide users through upgrading from Spring Boot 3.x to 4.x with clear, actionable steps.
Minimum Requirements
| Requirement | Version |
|---|---|
| Java | 17+ (21+ recommended) |
| Kotlin | 2.2+ |
| Maven | 3.6.3+ |
| Gradle | 8.14+ |
Key Dependencies Updated
Spring Framework 7.0, Spring Security 7.0, Jackson 3.0, Hibernate 7.1, JUnit 6, Jakarta EE 11
Migration Strategies
Strategy A: Gradual (6 Independent Tracks)
Use compatibility bridges for incremental adoption:
- Starters → Modular starters
- Jackson → Jackson 2 to 3
- Properties → Config updates
- Security → Spring Security 7
- Testing → Test infrastructure
- Framework → Spring Framework 7
Enable bridges:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-classic</artifactId>
</dependency>
Strategy B: All-at-Once (10 Phases)
Execute sequentially for smaller codebases or dedicated sprints.
Migration Phases
Phase 1: Pre-Migration
- Ensure on Spring Boot 3.5.x
- Fix all deprecation warnings
- Run full test suite (must pass)
- Create migration branch
Reference: references/pre-migration.md
Phase 2: Build Files
Update parent/plugin version to 4.0.0 and Java to 21.
Key starter changes:
| Category | Change |
|---|---|
| Web | starter-web → starter-webmvc |
| Security | Add -security- prefix (e.g., starter-security-oauth2-client) |
| Database | NEW starter-flyway, starter-liquibase (now required) |
| Batch | NEW starter-batch-jdbc (required for DB metadata) |
| Observability | NEW unified starter-opentelemetry |
| AOP | starter-aop → starter-aspectj |
| Undertow | REMOVED → use Jetty |
Reference: references/build-migration.md
Phase 3: Properties
Key renames:
| Old | New |
|---|---|
spring.dao.* |
spring.persistence.* |
management.tracing.enabled |
management.tracing.export.enabled |
Jackson restructuring: spring.jackson.* → spring.jackson.json.*
Reference: references/property-changes.md
Phase 4: Jackson 3
Package change: com.fasterxml.jackson.databind → tools.jackson.databind
Class renames: @JsonComponent → @JacksonComponent, JsonObjectSerializer → ObjectValueSerializer
Reference: references/jackson3-migration.md
Phase 5: API Changes
Package relocations (see references/api-changes.md)
Phase 6: Security 7
DSL changes: Remove .and() chaining, use lambdas
Matchers: antMatchers → requestMatchers
Reference: references/security7-migration.md
Phase 7: Testing
@MockBean → @MockitoBean
@SpyBean → @MockitoSpyBean
MockMvc requires @AutoConfigureMockMvc
Reference: references/testing-migration.md
Phase 8: Observability
NEW unified starter-opentelemetry
Reference: references/observability-migration.md
Phase 9: Framework 7
JSpecify annotations: org.springframework.lang.Nullable → org.jspecify.annotations.Nullable
Reference: references/framework7-changes.md
Phase 10: Verification
- Run tests
- Verify actuator endpoints
- Remove compatibility bridges
- Run
scripts/verify-migration.sh
Reference: references/verification-checklist.md
OpenRewrite Automation
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.spring.boot4.UpgradeSpringBoot_4_0</recipe>
</activeRecipes>
</configuration>
</plugin>
Run: mvn rewrite:run or ./gradlew rewriteRun
Quick Commands
| User Says | Action |
|---|---|
| "Migrate to Spring Boot 4" | Run pre-migration checks, guide through phases |
| "Upgrade from Boot 3.x" | Assess current version, recommend upgrade path |
| "Help with Jackson 3" | Load jackson3-migration.md, apply changes |
| "Migrate Security to 7" | Load security7-migration.md, apply changes |
| "Fix my tests" | Load testing-migration.md, fix MockBean issues |
More from ajaywadhara/agent-skills
design-doc
Generate complete engineering design documents with Mermaid diagrams from a single prompt. Creates architecture overviews (C4), data models (ERD), sequence diagrams, state machines, and decision logs. One-shot workflow with minimal back-and-forth. Use when designing systems, creating design docs, architecting features, or documenting architecture.
5openapi-architect
Design and generate OpenAPI 3.1 specifications following REST best practices. Creates API specs from requirements, reviews existing specs for compliance, implements RFC 7807 error handling, designs security schemes, and structures pagination/filtering. Use when designing APIs, creating OpenAPI specs, reviewing API design, or architecting REST endpoints.
4figma-to-code
Convert Figma designs into production UI code. Accepts Figma JSON exports, screenshots, or dev-mode snippets. Detects the project's existing frontend framework, design system, and component patterns — generates code that matches. Use when the user wants to build UI from Figma, convert Figma to code, implement a Figma design, or mentions "figma pack".
2commit-push-pr
Commit, push, and optionally create a PR for changes. Use when user says: commit my changes, commit and push, push my code, create a PR, commit push pr, or any variation requesting to commit/push changes to git.
2multi-module-scaffolder
Scaffold complete multi-module Gradle projects with Spring Boot 4, Java 21, and a production-grade exception handling architecture. Generates server, api-gateway, and common:exception modules with version catalog, GlobalExceptionHandler, ErrorCode enum, ErrorResponse record, and per-module exception hierarchy. Use when asked to scaffold a project, create a multi-module Gradle project, generate a new Spring Boot project, or set up a microservice skeleton.
2senior-eng-review
Mission-critical codebase audit for Senior Engineering Managers. Evaluates Reliability, Data Integrity (Payments), Architecture, and Quality against strict "Big Tech" standards (99.999% availability, Idempotency, Safety First).
1