Spring Boot 4.2.0-RC1 一跑 spring-boot:build-image,默认 builder 已经换成 paketobuildpacks/ubuntu-resolute-builder,镜像基线是 Ubuntu 26.04(Resolute Raccoon)。4.1.1 和 4.2.0-M2 还是 builder-noble-java-tiny(24.04)。同一次默认构建还会塞进 spring-cloud-bindings 2.0.4,容器一启动就因为找不到 org.springframework.boot.env.EnvironmentPostProcessor 挂掉;这个接口在 4.0 标了 forRemoval,4.2 里已经删掉。关掉 bindings 之后镜像能起来,curl 返回 hello-42-rc1。
环境是 Spring Boot 4.2.0-RC1、Spring Framework 7.1.0-RC1、JDK 21.0.12.1,BOM 从 Spring Milestone 拉。发行说明见 Spring Boot 4.2.0-RC1 Release Notes,标签 v4.2.0-RC1(2026-10-22T17:04:34Z)。站点上 Spring Boot 4.2.0-M2:LDAPS SSL Bundle 与 OTLP 语义约定 还停在 M2,这篇按 RC1 实际构建和启动写。
默认 builder 换成 ubuntu-resolute
gh-51249 把默认 builder 切到 resolute,里程碑就是 4.2.0-RC1。BuildRequest 里的常量对得上:
# 4.2.0-RC1
static final String DEFAULT_BUILDER_IMAGE_NAME = "paketobuildpacks/ubuntu-resolute-builder";
static final String DEFAULT_RUN_IMAGE_NAME = "paketobuildpacks/ubuntu-resolute-run-tiny";
# 4.1.1 / 4.2.0-M2
static final String DEFAULT_BUILDER_IMAGE_NAME = "paketobuildpacks/builder-noble-java-tiny";
不配 builder、直接 mvn spring-boot:build-image,日志里拉到的就是 resolute:
[INFO] > Pulled builder image 'paketobuildpacks/ubuntu-resolute-builder@sha256:e0e63bcda06248417da1ecc96047671a97e3afda665755f238b5bf78730a5f75'
[INFO] > Pulled run image 'paketobuildpacks/ubuntu-resolute-run-tiny@sha256:8c0c4ab9e41e11ea7ead2f359e469c9bf64ec2f3bb8ab92041061b345354ff16'
[INFO] Successfully built image 'docker.io/library/boot42-rc1-demo:local'
[INFO] BUILD SUCCESS
builder 镜像标签和 /etc/os-release:
stack=io.buildpacks.stacks.resolute version=26.04
PRETTY_NAME="Ubuntu 26.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="26.04"
VERSION="26.04.1 LTS (Resolute Raccoon)"
VERSION_CODENAME=resolute
应用镜像标签带 io.buildpacks.stacks.resolute.tiny 和 org.springframework.boot.version=4.2.0-RC1。发行说明里写:不配 builder 时 run image 默认 ubuntu-resolute-run-tiny(无 shell);自己指定 builder 才会跟到带 shell 的 ubuntu-resolute-run。要留在 24.04 就把 builder 设回 paketobuildpacks/builder-noble-java-tiny。
默认塞进的 spring-cloud-bindings 让容器起不来
第一次默认构建时 creator 下载了 bindings 2.0.4:
[INFO] [creator] $BP_SPRING_CLOUD_BINDINGS_DISABLED false whether to contribute Spring Boot cloud bindings support
[INFO] [creator] Downloading from https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-bindings/2.0.4/spring-cloud-bindings-2.0.4.jar
[INFO] Successfully built image 'docker.io/library/boot42-rc1-demo:with-bindings'
docker run 立刻失败:
Caused by: java.lang.IllegalArgumentException: Unable to instantiate factory class [org.springframework.cloud.bindings.boot.BindingFlattenedEnvironmentPostProcessor] for factory type [org.springframework.context.ApplicationListener]
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/env/EnvironmentPostProcessor
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.env.EnvironmentPostProcessor
Boot 4.1.1 的 spring-boot jar 里还有 org.springframework.boot.env.EnvironmentPostProcessor,源码标着 @Deprecated(since = "4.0.0", forRemoval = true),说明里写 for removal in 4.2.0,改用 org.springframework.boot.EnvironmentPostProcessor。4.2.0-RC1 的 jar 里这个旧接口已经没了,bindings 2.0.4 还在引用旧包名。这是对着两个版本的 class 列表和 4.1.1 源码对出来的,不是猜的。
在 spring-boot-maven-plugin 里加上:
<image>
<env>
<BP_SPRING_CLOUD_BINDINGS_DISABLED>true</BP_SPRING_CLOUD_BINDINGS_DISABLED>
</env>
</image>
重建后 creator 显示 $BP_SPRING_CLOUD_BINDINGS_DISABLED true,不再下 bindings jar。容器起来后:
2026-10-22T17:26:40.006Z INFO 1 --- [boot42-rc1-demo] [ main] o.s.boot.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'
2026-10-22T17:26:40.012Z INFO 1 --- [boot42-rc1-demo] [ main] c.e.boot42.Boot42Rc1DemoApplication : Started Boot42Rc1DemoApplication in 1.583 seconds (process running for 1.909)
curl=hello-42-rc1
properties-migrator 的 fail 开关
RC1 还给 spring-boot-properties-migrator 加了 spring.properties.migrator.fail,取值 never(默认)、on-error、on-warning。依赖进 runtime 即可。
改名键(warning)配 on-error 时进程仍退出 0;换成已删除的 spring.banner.image.width(error)再配 on-error,启动失败:
$ java -jar target/boot42-rc1-demo-0.0.1-SNAPSHOT.jar --spring.banner.image.width=76 --spring.properties.migrator.fail=on-error
The use of configuration keys that are no longer supported was found in the environment:
Property source 'commandLineArgs':
Key: spring.banner.image.width
Reason: Support for image banners has been removed.
java.lang.IllegalStateException: Found configuration keys that need to be migrated
exit=1
改名键配 on-warning 同样 exit=1:
$ java -jar target/boot42-rc1-demo-0.0.1-SNAPSHOT.jar --spring.resources.add-mappings=false --spring.properties.migrator.fail=on-warning
The use of configuration keys that have been renamed was found in the environment:
Property source 'commandLineArgs':
Key: spring.resources.add-mappings
Replacement: spring.web.resources.add-mappings
java.lang.IllegalStateException: Found configuration keys that need to be migrated
exit=1
默认不设 fail(等同 never)时两种键都只打日志,进程 exit=0。
版本边界
Ubuntu resolute 默认 builder、run image 兼容检查改看 distro 标签、spring.properties.migrator.fail,都是 4.2.0-RC1 Release Notes 明文新内容;4.1.x / 4.2.0-M2 的 BuildRequest 仍指向 noble。org.springframework.boot.env.EnvironmentPostProcessor 的删除落在 4.2,4.1.1 里还能加载到。bindings 启动失败是这次默认构建实测到的,发行说明没有单独写这一条。
一起交流
分享你的思考,让讨论更进一步。