Generated banner for Spring Boot 4 Migration
Generated logo for Spring Boot 4 Migration

Spring Boot 4 Migration

GitHubOfficialFirst committed by jduboisDistributed by GitHub

  • Skill
  • Workflow
  • Software development
  • MIT
  • No issues found

From the author

Migrate a Spring Boot 3.x application to Spring Boot 4.0 (Spring Framework 7, Jackson 3, modular starters, JSpecify). Use only for an explicit Boot 3.x to 4 migration, or to fix build or test failures caused by it, or to review one. Not for 3.x patch bumps or 4.0 to 4.1 upgrades; follow the target Boot version release notes and upgrade guide for those. Covers Maven and Gradle (Kotlin DSL, version catalogs).
— the description by jdubois

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a systematic approach to upgrading Spring Boot applications from version 3.x to 4.0. It covers critical architectural changes, including the shift to Spring Framework 7, Jackson 3, and modular starters. The workflow emphasizes a methodical, incremental migration process—starting with a baseline at the latest 3.5.x version—to ensure build stability and test integrity throughout the transition. It supports both Maven and Gradle (including Kotlin DSL and version catalogs) and provides guidance on handling configuration properties, testing framework updates, and observability modules.

What it does

  • Guides the user through a multi-step migration process from Spring Boot 3.x to 4.0.
  • Provides instructions for updating build configurations in Maven and Gradle.
  • Details the transition to modular starters and Jackson 3.
  • Offers a checklist for verifying build, tests, and runtime health.
  • Includes references for specific migration topics like testing, security, and observability.
  • Suggests using OpenRewrite recipes where available to automate parts of the migration.

When to use it

  • When performing an explicit migration from a Spring Boot 3.x application to 4.0.
  • When troubleshooting build or test failures specifically caused by a 3.x to 4.0 migration.
  • When reviewing a codebase that has undergone a 3.x to 4.0 migration.
  • When you need to identify the correct order of operations for updating dependencies and configuration.

Advantages

  • Promotes a safe, incremental migration strategy that minimizes breaking changes.
  • Provides clear guidance on handling complex changes like Jackson 3 and modular starters.
  • Supports both Maven and Gradle build systems.
  • Includes a final verification checklist to ensure application stability.
  • Directs users to official documentation for deep-dive technical details.

Usage examples

“How do I start migrating my Spring Boot 3.2 application to 4.0?”
The agent will guide you to first upgrade to the latest 3.5.x version, establish a baseline with passing tests, and then proceed with the 4.0 migration steps.
“I am getting build errors after updating to Spring Boot 4.0 regarding Jackson. What should I do?”
The agent will point you to the Jackson 3 migration reference, explaining the package renames and the use of the temporary compatibility module.
“How should I handle the new modular starters in my Gradle build?”
The agent will explain the difference between technology-specific starters and classic starters, providing examples for your libs.versions.toml and build.gradle.kts files.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/github/spring-boot-4-migration/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip spring-boot-4-migration.zip -d .agents/skills

Documentation by jdubois

Spring Boot 3.x to 4.0 Migration

Step-by-step migration workflow. Topic details live in references/; load only the files relevant to the current step.

Rules

  • Never read or print secrets (.env, credentials, tokens in properties files).

  • Change one thing per step and run the test suite after each step; commit nothing you cannot build.

  • Pin versions explicitly; never use latest or open-ended ranges.

  • Check the official sources when unsure: the Spring Boot 4.0 Migration Guide on the Spring Boot GitHub wiki and the release notes on spring.io.

Workflow

  1. Detect the current state

    • Boot version: pom.xml (spring-boot-starter-parent / BOM version), build.gradle(.kts) (org.springframework.boot plugin), or gradle/libs.versions.toml.

    • Build tool: pom.xml + mvnw means Maven; build.gradle.kts / build.gradle means Gradle (Kotlin or Groovy DSL). Use the project wrapper (./mvnw, ./gradlew).

    • Java version (Boot 4 needs Java 17+, Java 25 recommended), Kotlin version, and key libraries (Jackson, Hibernate, Security, Kafka, Elasticsearch, MongoDB).

    • See prerequisites.

  2. Migrate to the latest 3.5.x first. If the project is older than 3.5, upgrade to the latest 3.5.x, fix deprecation warnings, and get the tests green before touching 4.0. Never jump from 3.2 straight to 4.0.

  3. Baseline: run the full build and tests (./mvnw verify or ./gradlew build) and record failures that exist before migration.

  4. Bump to 4.0.x (parent/BOM or plugin version) and fix the build in this order, running the build after each item:

    1. Starters and modules: starters and removed features. Choose either the classic starters or the new modular ones; Boot 4 split the auto-configuration into many modules, and each technology now has its own *-test starter.

    2. Build files and third-party dependencies: build and dependencies and Kotlin/Java build config.

    3. Jackson 3 (new tools.jackson packages): Jackson 3. A temporary Jackson 2 compatibility module exists; plan to remove it.

    4. Core framework (JSpecify nullability, package relocations, logging, DevTools, PropertyMapper): core framework.

    5. Configuration properties (MongoDB, Spring Session, persistence, Kafka retry): configuration properties. Add spring-boot-properties-migrator temporarily to find renamed keys, and remove it afterwards.

    6. Web and messaging changes (trailing slash matching, HttpMessageConverters, Jersey, Kafka, RabbitMQ): web and messaging.

    7. Tests (Mockito/@MockBean replacement, @SpringBootTest changes, @PropertyMapping): testing.

    8. Actuator and observability modules, health probes: actuator and observability.

  5. Verify with the checklist, pitfalls and resources: full build, tests, startup, actuator health, a smoke test of the main endpoints, and native image build if used.

Build tool notes

  • Maven: change the parent (or spring-boot-dependencies BOM) version, then swap starters in <dependencies>. Use ./mvnw dependency:tree to find stale transitive Jackson 2, Undertow, or Spring Retry usage. The reference files show Gradle snippets; translate the coordinates directly to Maven <dependency> entries.

  • Gradle Kotlin DSL: update the plugin version in plugins {} or the version catalog; use ./gradlew dependencies --configuration runtimeClasspath to inspect resolution.

  • Keep the Spring Boot version in a single place (parent, BOM property, or version catalog entry).

Reference files

FileTopic
01-prerequisites.mdMinimum versions, pre-migration steps
02-starters-and-removed-features.mdModular starters, renamed starters, removed servers/features
03-jackson-3.mdJackson 3 packages, renames, compatibility module
04-core-framework.mdJSpecify, package moves, logging, DevTools, PropertyMapper
05-build-and-dependencies.mdGradle plugin, Spring Retry, Authorization Server, Elasticsearch, Hibernate
06-configuration-properties.mdRenamed and restructured properties
07-web-and-messaging.mdWeb framework, Kafka, RabbitMQ changes
08-testing.mdTest framework changes
09-actuator-and-observability.mdActuator, Micrometer and OpenTelemetry modules
10-kotlin-and-java-build-config.mdKotlin compiler and Java preview configuration
11-checklist-pitfalls-resources.mdFinal checklist, pitfalls, links

Automation

Use OpenRewrite (org.openrewrite.java.spring.boot4.UpgradeSpringBoot_4_0, https://docs.openrewrite.org/recipes/java/spring/boot4/upgradespringboot_4_0-community-edition) when available, review the diff, and always fetch the version-specific official guide before editing.

Upstream sources (read before migrating)

Fetch the page for the target version; prefer it over this skill when they conflict.

For Boot 3.x patch bumps or Boot 4.0 to 4.1 upgrades, go directly to the target Boot version's release notes and upgrade guide using the official links above. These are dependency upgrades, not JDK migrations; do not route them to java-upgrade.

Related skills, each only if installed (otherwise use the fallback in parentheses):

  • spring-security (Security 7 changes): fall back to the Spring Security 7 migration guide above.

  • spring-observability: fall back to actuator and observability and the Micrometer guide above.

  • java-hibernate-jpa: fall back to the Hibernate ORM 7 migration guide above.

  • java-upgrade (only when a JDK upgrade is explicitly requested): fall back to the target JDK's official migration guide.

  • java-diagnostics (runtime or startup failures): read the full stack trace and mvn dependency:tree / gradle dependencies output yourself.

  • java-testcontainers (Testcontainers 2.0 tests): see testing and the Testcontainers 2 migration notes.

  • kotlin-springboot (Kotlin specifics): see Kotlin and Java build config.

Files

references/05-build-and-dependencies.md

Dependency and Build Changes

Gradle Plugin Updates

build.gradle.kts:

plugins {
    kotlin("jvm") version "2.2.0" // Minimum 2.2.0
    kotlin("plugin.spring") version "2.2.0"
    id("org.springframework.boot") version "4.0.x" // use the current 4.0 patch
    id("io.spring.dependency-management") version "1.1.7"
    id("org.cyclonedx.bom") version "3.0.0" // Minimum 3.0.0
}

Verified: Boot 3.5 -> 4.x with Kotlin 2.2.0 builds (Groovy and Kotlin DSL, Gradle 9.8.1). Boot 4.x manages a newer Kotlin than Boot 3.5 (1.9.25), so with the dependency-management/BOM the Kotlin plugin version should ideally follow it. Run Gradle on JDK 21 or 25: the Kotlin 1.9 compiler fails with IllegalArgumentException: 27 under JDK 27.

Optional Dependencies in Gradle

Optional dependencies are no longer included in uber jars by default. Gradle has no Maven-style optional scope and BootJar has no includeOptional property, so control packaging through the dependency configuration instead:

dependencies {
    implementation("group:artifact")   // compile and runtime classpath, packaged in the jar
    runtimeOnly("group:artifact")      // runtime only, packaged in the jar
    compileOnly("group:artifact")      // compile time only, not packaged
}

If a dependency that used to be optional is now missing at runtime, move it to implementation or runtimeOnly.

Spring Retry → Spring Framework Core Retry

Spring Boot 4.0 removes dependency management for Spring Retry (portfolio migrating to Spring Framework 7.0 core retry).

Migration Option 1: Use Spring Framework Core Retry (Recommended)

// Use built-in Spring Framework retry
import org.springframework.core.retry.RetryTemplate
import org.springframework.core.retry.RetryPolicy
import java.time.Duration

@Configuration
class RetryConfig {
    @Bean
    fun retryTemplate(): RetryTemplate {
        val policy = RetryPolicy.builder()
            .maxRetries(3)
            .delay(Duration.ofMillis(1000))
            .build()
        return RetryTemplate(policy)
    }
}

Migration Option 2: Explicit Spring Retry Version (Temporary)

libs.versions.toml:

[versions]
spring-retry = "2.0.5" # Explicit version required

[libraries]
spring-retry = { module = "org.springframework.retry:spring-retry", version.ref = "spring-retry" }

Plan migration to Spring Framework core retry.

Spring Authorization Server

Now part of Spring Security - explicit version management removed.

libs.versions.toml (before - Spring Boot 3.x):

[versions]
spring-authorization-server = "1.3.0" # No longer works

[libraries]
spring-security-oauth2-authorization-server = { module = "org.springframework.security:spring-security-oauth2-authorization-server", version.ref = "spring-authorization-server" }

Migration (Spring Boot 4.0):

[versions]
spring-security = "7.0.0" # Use Spring Security version instead

[libraries]
# Managed by spring-security.version property, not separate
spring-security-oauth2-authorization-server = { module = "org.springframework.security:spring-security-oauth2-authorization-server", version.ref = "spring-security" }

Or rely on Spring Boot dependency management (recommended):

dependencies {
    implementation("org.springframework.security:spring-security-oauth2-authorization-server")
    // Version managed by Spring Boot 4.0
}
Elasticsearch Client Changes
Low-Level Client Replacement

Deprecated low-level RestClient → new Rest5Client:

Note: Higher-level clients (ElasticsearchClient and Spring Data's ReactiveElasticsearchClient) remain unchanged and have been updated internally to use the new low-level client.

Imports:

// Old (Spring Boot 3.x)
import org.elasticsearch.client.RestClient
import org.elasticsearch.client.RestClientBuilder
import org.springframework.boot.autoconfigure.elasticsearch.RestClientBuilderCustomizer

// New (Spring Boot 4.0)
import co.elastic.clients.transport.rest5_client.low_level.Rest5Client
import co.elastic.clients.transport.rest5_client.low_level.Rest5ClientBuilder
import org.springframework.boot.elasticsearch.autoconfigure.Rest5ClientBuilderCustomizer
import org.apache.hc.client5.http.config.ConnectionConfig
import org.apache.hc.core5.util.Timeout

Configuration:

@Configuration
class ElasticsearchConfig {

    // Old
    // @Bean
    // fun restClientCustomizer(): RestClientBuilderCustomizer {
    //     return RestClientBuilderCustomizer { builder ->
    //         builder.setRequestConfigCallback { config ->
    //             config.setConnectTimeout(5000)
    //         }
    //     }
    // }

    // New
    @Bean
    fun rest5ClientCustomizer(): Rest5ClientBuilderCustomizer {
        return object : Rest5ClientBuilderCustomizer {
            override fun customize(builder: Rest5ClientBuilder) {}

            // Dedicated callbacks replace setRequestConfigCallback
            override fun customize(builder: ConnectionConfig.Builder) {
                builder.setConnectTimeout(Timeout.ofSeconds(5))
            }
        }
    }
}

Dependency Consolidation:

Sniffer now included in co.elastic.clients:elasticsearch-java module.

libs.versions.toml:

[libraries]
# Remove these - no longer managed
# elasticsearch-rest-client = { module = "org.elasticsearch.client:elasticsearch-rest-client", version = "..." }
# elasticsearch-rest-client-sniffer = { module = "org.elasticsearch.client:elasticsearch-rest-client-sniffer", version = "..." }

# Use single dependency (includes sniffer); let the Boot BOM select the compatible client
elasticsearch-java = { module = "co.elastic.clients:elasticsearch-java" }
Hibernate Dependency Changes

libs.versions.toml:

[libraries]
# Renamed module (hibernate-jpamodelgen replaced by hibernate-processor)
hibernate-processor = { module = "org.hibernate.orm:hibernate-processor", version.ref = "hibernate" }

# These artifacts are NO LONGER PUBLISHED by Hibernate:
# hibernate-proxool - discontinued by Hibernate project
# hibernate-vibur - discontinued by Hibernate project
# Remove any dependencies on these modules

Note: hibernate-jpamodelgen artifact still exists but is deprecated. Use hibernate-processor going forward.

Requirements and compatibility

Written for: GitHub Copilot

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

First committed by
GitHub avatar of jduboisjdubois
Publisher
GitHub (Official)
Distributed by
GitHub
Source
github/awesome-copilot · skills/spring-boot-4-migration · commit 797337f
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Contributors
jdubois

AutoGineer is not affiliated with or endorsed by jdubois or GitHub.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download spring-boot-4-migration.zip