Index of every page on this site: llms.txt
All skills
github avatar

/spring-boot-4-migration

@f10fdb8 official
by githubgithub/awesome-copilot42k stars
5,426
Run it yourself

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).

Use this Skill: https://skilld.dev/gh/github/awesome-copilot/spring-boot-4-migration

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

references05-build-and-dependencies.md

≈1.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

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.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning22d3 checks · Risk SAFE
  • Gen Agent Trust Hub22d

    The skill provides a legitimate and well-documented workflow for migrating Spring Boot applications from version 3.x to 4.0. It includes comprehensive references for dependency changes, property renames, and framework updates. No malicious patterns were detected.

  • Socket22d

    No alerts

  • Snyk22d

    Risk: MEDIUM · 1 issue

Signed by skilld at f10fdb8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated last month

README badge

README badge for github/awesome-copilot/spring-boot-4-migration