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.

references04-core-framework.md

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

Core Framework Changes

Nullability Annotations: JSpecify

Spring Boot 4.0 adds JSpecify nullability annotations throughout the codebase.

Impact:

  • Kotlin null-safety may flag new warnings/errors
  • Null checkers (SpotBugs, NullAway) may report new issues
  • RestClient methods like body() are now explicitly marked as nullable - always check for null or use Objects.requireNonNull()

Migration for Kotlin:

// Explicit nullable types may be required
fun processUser(id: String?): User? {
    val nonNullId = id ?: return null // findById now requires a non-null ID
    return userRepository.findById(nonNullId).orElse(null) // Optional<User> -> User?
}

// RestClient body() can return null
val body: String? = restClient.get()
    .uri("https://api.example.com/data")
    .retrieve()
    .body(String::class.java) // Nullable - handle appropriately

if (body != null) {
    println(body.length)
}

Actuator endpoint parameters:

  • Cannot use javax.annotations.NonNull or org.springframework.lang.Nullable
  • Use org.jspecify.annotations.Nullable instead

libs.versions.toml:

[libraries]
jspecify = { module = "org.jspecify:jspecify", version = "1.0.0" }

Package Relocations

BootstrapRegistry

Old import:

import org.springframework.boot.BootstrapRegistry

New import:

import org.springframework.boot.bootstrap.BootstrapRegistry
EnvironmentPostProcessor

Old import:

import org.springframework.boot.env.EnvironmentPostProcessor

New import:

import org.springframework.boot.EnvironmentPostProcessor

Update META-INF/spring.factories:

# Old
org.springframework.boot.env.EnvironmentPostProcessor=com.example.MyPostProcessor

# New
org.springframework.boot.EnvironmentPostProcessor=com.example.MyPostProcessor

Note: Deprecated form still available temporarily but will be removed.

Entity Scan

Old import:

import org.springframework.boot.autoconfigure.domain.EntityScan

New import:

import org.springframework.boot.persistence.autoconfigure.EntityScan

Logging Changes

Logback Default Charset

Log files now default to UTF-8 (harmonized with Log4j2):

logback-spring.xml (explicit configuration):

<configuration>
    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>app.log</file>
        <encoder>
            <charset>UTF-8</charset> <!-- Now default -->
            <pattern>%d{yyyy-MM-dd HH:mm:ss} - %msg%n</pattern>
        </encoder>
    </appender>
</configuration>

Console logging: Uses Console#charset() if available (Java 17+), otherwise falls back to UTF-8. This provides better platform compatibility while maintaining consistent encoding.

DevTools Changes

Live Reload Disabled by Default

application.yml:

spring:
  devtools:
    livereload:
      enabled: true # Must explicitly enable in 4.0

libs.versions.toml:

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

build.gradle.kts:

dependencies {
    developmentOnly(libs.spring.boot.devtools)
}

PropertyMapper API Behavioral Change

Breaking change: No longer calls adapter/predicate methods by default when source is null.

Migration pattern:

// Old behavior (Spring Boot 3.x)
map.from(source::method).to(destination::method)
// Calls destination.method(null) if source returns null

// New behavior (Spring Boot 4.0)
map.from(source::method).to(destination::method)
// Skips call if source returns null

// Explicit null handling (new)
map.from(source::method).always().to(destination::method)
// Always calls destination.method(value), even if null

Removed method: alwaysApplyingNotNull() - remove this configuration: Boot 4 skips null source values by default. Do not replace it with always(), which explicitly passes nulls through; reserve always() for mappings that intentionally accept null.

Migration example: Review Spring Boot commit 239f384ac0 to see how Spring Boot itself adapted to the new API.

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