🤔 Should You Upgrade Now? Link to heading

Spring Boot 4.2.0 shipped on November 19, 2026, on Spring Framework 7.1. On 4.0, upgrade soon: open-source support for 4.0.x ends on December 31, 2026. On 4.1, you have until July 31, 2027, and the reasons to move are operational: faster startup, buildpack caches your CI runners can share, and OpenTelemetry’s semantic conventions.

The code changes are small. The real cost is behavior that changes without a compile error: forwarded headers, redirects, Redis, metrics and the base image.

One trap is loud: the 4.2 notes say the Paketo Spring Boot buildpack turns on Spring Cloud Bindings, which isn’t compatible with 4.2 and “causes a startup failure as the org.springframework.boot.env.EnvironmentPostProcessor class cannot be found”. If you build images with buildpacks, set BP_SPRING_CLOUD_BINDINGS_DISABLED=true when you build them.

This is the sequel to Migrating a Kotlin Service from Spring Boot 3 to 4. That jump was compiler work; this one is config, tests and CI. Upgrade for the operational wins and a supported line, not for the version number.


📅 The Decision: Where You Are Decides When Link to heading

Your starting version sets the deadline, not the release.

You’re on OSS support ends Commercial support ends What to do
3.5.x 2026-06-30 (ended) 2032-06-30 Move to 4.x, or pay for support on purpose
4.0.x 2026-12-31 2027-12-31 Move before the year ends
4.1.x 2027-07-31 2028-07-31 No rush; plan 4.2 for the next quarter or two
4.2.x 2027-12-31 2028-12-31 Take the patches

Take the latest patch of whichever line you land on: 4.0.10, 4.1.3 or 4.2.0 today.

On 4.0, you have two options.

  • 4.1.3 now, 4.2 later. A smaller change this month and support to July 31, 2027, but two upgrades before the end of July.
  • 4.2.0 now. One hop and support to December 31, 2027, but both sets of upgrade notes and the base-image change at once. The rollout below splits that risk back out.

My lean: go straight to 4.2 if the service has good tests at its HTTP edge. Take 4.1.3 first if it doesn’t, so you test each release’s changes on their own.

On 4.1, move now if you want one of the payoffs below. Wait while a dependency Boot doesn’t manage has no 4.2 release yet: check that your Spring Cloud release train supports 4.2 before you start.

Pulsar users don’t need to wait. Boot’s Pulsar support is deprecated, after the project moved to the Apache Software Foundation, but 4.2 manages the same Spring for Apache Pulsar version as 4.1. Plan the move with the project’s migration guide.

Waiting for the first patch is fine on 4.1, with eight months left. Not on 4.0.

Staying put is only honest with commercial support: 3.5.x has it until June 30, 2032, and 4.0.x until December 31, 2027. Otherwise you’re running unpatched, and Java4Shell showed that a security fix is an upgrade on someone else’s schedule.

On 3.5, follow the Boot 3 → 4 path, but aim for 4.1 or 4.2, not 4.0. On Kotlin, Boot 4.2 manages Kotlin 2.4.21, where 4.1 managed 2.3.21.


💸 What It Costs: Loud Breaks, Quiet Changes, Build Changes Link to heading

Sizing the work is triage: loud failures are cheap, and silent behavior changes need a test or a dashboard to catch them.

First, the notes say classes, methods and properties deprecated in 4.0 are removed in 4.2. Clear your deprecation warnings before you bump.

Loud: fails at startup or compile

If you… What happens What to do
use spring-boot-starter-amqp for RabbitMQ It now means AMQP 1.0; classes moved to org.springframework.boot.rabbitmq Switch to spring-boot-starter-rabbitmq
set both server.forward-headers-strategy and server.request.header.forwarded.strategy Startup fails Keep only the new one
run Tomcat with rfc-7239 naming or use-prefix, or Jetty with use-prefix Startup fails Use the framework strategy
build images with Paketo’s Spring Boot buildpack Spring Cloud Bindings fails startup Set BP_SPRING_CLOUD_BINDINGS_DISABLED=true
use an SSL bundle with options for gRPC, LDAP, or the OTLP tracing or logging exporters Startup fails; they used to be ignored Use a bundle without options
define a deprecated Micrometer JVM convention and its replacement Fails fast Keep the replacement
enable embedded LDAP SSL without a bundle A bundle is now required Set spring.ldap.embedded.ssl.bundle

In the sample, Tomcat with the web-server strategy and use-prefix fails with a bare stack trace:

org.springframework.context.ApplicationContextException: Unable to start web server
Caused by: java.lang.IllegalStateException: Tomcat does not support RFC 7239 or 'prefix' forwarded header

Quiet: changes behavior with no error

Change Affected if… How to check To restore the old behavior
X-Forwarded-Prefix is ignored by default Your proxy sets it and you build links from the request A live-server test server.request.header.forwarded.use-prefix=true (with the framework strategy on Tomcat)
Tomcat’s use-relative-redirects defaults to true Clients expect an absolute Location A live-server test on a redirect server.tomcat.servlet.use-relative-redirects=false
The Redis database now applies to master/replica connections You set spring.data.redis.database with masterreplica.nodes Your config: you used database 0 until now Remove the database setting, or set 0
WebFlux multipart limits: 1MB of disk per part, 50 parts You accept bigger uploads on WebFlux An upload test at your real maximum Raise spring.webflux.multipart.max-disk-usage-per-part and max-parts, or set -1
No LongTaskTimer for active observations Dashboards read meters like http.server.requests.active Check the meter exists after a request management.metrics.observations.include-active-long-task-timer=true
liveness and readiness groups keep their default members You configure more than include/exclude on them Compare probes in staging No switch given

Also quiet: management.tracing.baggage.tag-fields now become OpenTelemetry span tags, test MeterRegistry beans leave Micrometer’s global registry, and Boot’s Set and Map properties keep config-file order.

The sample has canaries for the prefix, redirect and timer rows. On 4.1.3, 6 of its 19 tests fail. The redirect test gets http://localhost:52020/quotes/1 instead of /quotes/1, and the timer test, which expects no active-request timer, finds one. The forwarded-header tests fail because 4.1 silently ignores server.request.header.forwarded.*, so setting 4.2’s names early does nothing.

Build and CI only: the image builder moves to Ubuntu 26.04 (below), Boot stops managing Janino, Maven’s useTestClasspath gives way to testClasspath, and three Tomcat properties moved under server.tomcat.servlet.

Count your quiet rows. That’s your test-writing budget, and it’s most of the upgrade.

Coming from 4.0? Add the 4.1 notes Link to heading

  • The layertools jar mode is gone; Dockerfiles move to tools. It’s the likeliest CI break.
  • Maven’s -DskipTests no longer skips test AOT processing; use maven.test.skip.
  • JPA bootstrap-mode: deferred now throws without a suitable AsyncTaskExecutor bean.
  • Reactor HTTP client builders now apply proxyWithSystemProperties(), which is quiet if JVM proxy properties are set.
  • Constructor-bound Optional properties bind as Optional.empty(), not null.

🎁 What It Pays: Startup, CI Caches, Telemetry Link to heading

The payoffs are operational, and the notes give no numbers, so measure them yourself.

Startup. Executable jars now look classes up directly in nested jars, instead of opening a URL connection per nested jar per lookup. The notes say this “reduces startup time and the memory allocated during startup”. It’s automatic. They give no figure, and I won’t invent one. From the mechanism, services with many dependencies that start often should gain most. Compare the median “Started … in N seconds” over several starts, old version against new.

CI cache warmth. Buildpack builds can keep the build cache (buildCache) as an image in a registry, so ephemeral CI runners share a warm cache. The Gradle plugin docs show the setup.

Telemetry consistency, in the order I’d value it across many services:

  1. Common OTLP config. Set the endpoint, headers and compression once under management.opentelemetry.otlp, for traces, logs and metrics. Signal-specific properties still win.
  2. OpenTelemetry semantic conventions, opt-in with management.observations.conventions=open-telemetry. Properties that customize meter names, such as management.observations.http.server.requests.name, then stop working, so it’s a dashboard migration, not a config tweak.
  3. Configurable MDC keys for trace and span IDs (management.tracing.mdc.trace-id-key).

A CI gate. The properties migrator can now fail the application. Per the 4.2.0 jar’s configuration metadata, set spring.properties.migrator.fail to on-warning (or on-error; the default is never) and a renamed property fails startup in CI instead of scrolling past.

The release notes cover the rest. If AI features are on your roadmap, my Spring AI 2.1 example runs on Boot 4.2.


🔁 Is RestTemplate Deprecated? Moving to RestClient Without a Rewrite Link to heading

Yes, for removal, but it still works. Spring Framework 7.1 deprecates RestTemplate for removal, and Boot 4.2 deprecates RestTemplateBuilder, RestTemplateCustomizer, the auto-configurations and TestRestTemplate with it.

The javadoc has dates the release notes don’t: Framework 7.1’s RestTemplate says “For removal in 8.0”, and Boot 4.2’s RestTemplateBuilder, RestTemplateCustomizer and TestRestTemplate say “since 4.2.0 for removal in 4.4.0”. It doesn’t block 4.2. I’d stop writing new RestTemplate code today and migrate client by client.

1. Count with grep, not warnings. Search for RestTemplate, TestRestTemplate and MockRestServiceServer; the compiler undercounts. On 4.2.0, the sample’s build warns only where a deprecated type is named:

w: src/main/kotlin/quotes/HttpClientConfig.kt:21:44 'interface RestTemplateCustomizer : Any' is deprecated. Deprecated in Java.
w: src/main/kotlin/quotes/LegacyQuoteClient.kt:10:14 'class RestTemplateBuilder : Any' is deprecated. Deprecated in Java.

Kotlin didn’t warn on the RestTemplate itself, on calls through Framework’s getForObject<T>() extension, or on a customizer bean with no declared return type. On 4.1.3, the same code compiles cleanly.

2. Add a RestClientCustomizer next to each RestTemplateCustomizer. Add it; don’t swap it. A RestClientCustomizer doesn’t reach RestTemplateBuilder: with the old bean removed, the sample’s legacy client sent Java-http-client/17.0.7 as its user agent instead of the app’s. Keep both until the last legacy client is gone:

@Configuration(proxyBeanMethods = false)
class HttpClientConfig {

    @Bean
    fun userAgentRestClientCustomizer(): RestClientCustomizer = RestClientCustomizer { builder ->
        builder.defaultHeader(HttpHeaders.USER_AGENT, USER_AGENT)
    }

    @Bean
    fun userAgentRestTemplateCustomizer(): RestTemplateCustomizer = RestTemplateCustomizer { restTemplate ->
        restTemplate.interceptors.add(ClientHttpRequestInterceptor { request, body, execution ->
            request.headers.set(HttpHeaders.USER_AGENT, USER_AGENT)
            execution.execute(request, body)
        })
    }
}

3. Migrate one client per PR, behind its interface. The client takes a RestClient.Builder instead of a RestTemplateBuilder, and callers still see QuoteSource. Before:

@Component
class LegacyQuoteClient(
    builder: RestTemplateBuilder,
    @Value("\${quotes.base-url}") baseUrl: String,
) : QuoteSource {

    private val restTemplate = builder.baseUri(baseUrl).build()

    override fun quote(id: Long): Quote =
        checkNotNull(restTemplate.getForObject<Quote>("/quotes/{id}", id))
}

After:

@Component
class QuoteClient(
    builder: RestClient.Builder,
    @Value("\${quotes.base-url}") baseUrl: String,
) : QuoteSource {

    private val restClient = builder.baseUrl(baseUrl).build()

    override fun quote(id: Long): Quote =
        restClient.get()
            .uri("/quotes/{id}", id)
            .retrieve()
            .requiredBody<Quote>()
}

requiredBody<Quote>() returns a non-null Quote; body<Quote>() returns Quote?. A contract test run against both clients shows the swap kept the behavior. For a client too big for one PR, Framework 7.1’s RestClient.create(restTemplate) and RestClient.builder(restTemplate) copy the template’s request factory, converters, interceptors and error handler.

4. Point @RestClientTest at the new client. @RestClientTest(QuoteClient::class) binds MockRestServiceServer to the auto-configured RestClient.Builder. It doesn’t scan @Configuration classes, so @Import your customizer config.

Both clients and every test in this post are in the sample: download it as a zip.

TestRestTemplate → RestTestClient Link to heading

Annotate the test class with @AutoConfigureRestTestClient and a RestTestClient is injected. With RANDOM_PORT or DEFINED_PORT, it calls a live server. In a @WebMvcTest, it goes through MockMvc.

That choice matters for this upgrade. Here’s the sample’s redirect canary:

@SpringBootTest(webEnvironment = RANDOM_PORT)
@AutoConfigureRestTestClient
class RelativeRedirectsByDefaultTest(@Autowired private val client: RestTestClient) {

    @Test
    fun `Tomcat sends a relative Location`() {
        client.get().uri("/old-quotes/1")
            .exchange()
            .expectStatus().isFound
            .expectHeader().location("/quotes/1")
    }
}

It fails on 4.1.3. The same assertion in a @WebMvcTest passes on both versions, because no Tomcat is involved. Keep at least one live-server test per service, aimed at redirects and links built from the request: that’s what catches the quiet changes.

Migrate one test class per PR, starting with Kotlin tests that use Boot’s getForObject<T>() extension on TestRestTemplate. In 4.2.0, its vararg overload is deprecated at error level, so restTemplate.getForObject<Quote>("/quotes/2") stops compiling:

'fun <reified T : Any> TestRestTemplate.getForObject(url: String, vararg uriVariables: Any): T?' is deprecated. in favor of RestTestClient.

It’s the only extension in Boot’s TestRestTemplateExtensions.kt marked that way, which looks like an oversight. On 4.2.0, it’s still a compile error.


🐧 The Buildpack Base Image Moved to Ubuntu 26.04 Link to heading

If you build images with Boot’s plugins, 4.2 changes your OS. Treat that as its own change, separate from the framework bump.

The default builder is now paketobuildpacks/ubuntu-resolute-builder, replacing paketobuildpacks/builder-noble-java-tiny, so images are based on Ubuntu 26.04 instead of 24.04. The trap is the run image:

  • With builder not set, it’s paketobuildpacks/ubuntu-resolute-run-tiny:latest, with no shell, as before.
  • With builder set, it comes from the builder’s metadata: paketobuildpacks/ubuntu-resolute-run:latest, which has a shell.

So pinning the builder for reproducibility also adds a shell, unless you set runImage too. And the builder no longer pins the run image’s version, so reproducible images need both pinned. To keep the old builder for now, set builder to paketobuildpacks/builder-noble-java-tiny. To move and pin, set both, with the Spring Cloud Bindings workaround:

tasks.bootBuildImage {
    builder = "paketobuildpacks/ubuntu-resolute-builder:<pinned-version>"
    runImage = "paketobuildpacks/ubuntu-resolute-run-tiny:<pinned-version>"
    environment.put("BP_SPRING_CLOUD_BINDINGS_DISABLED", "true")
}

This DSL compiles against the 4.2.0 plugin. The tags are placeholders: take real versions from the registry.

The checks I’d add to the image pipeline:

  • Re-baseline the scanner, and review suppressions written against 24.04 packages.
  • Decide shell or no shell on purpose, and assert it in CI.
  • Check scripts that exec into containers. My Java4Shell triage shows how to reach java through the buildpack launcher on shell-less images.
  • Keep the SBOM. The tools jar mode has a new sbom command that prints and exports it.

🛤️ A Staged Rollout with Success Metrics Link to heading

Each stage changes one kind of thing and has a metric that says keep going or roll back.

0. Pick the target. On 4.0, work back from December 31: stages 1 and 2 put you on a supported line, and the rest can follow after the deadline. Ships when: each service has a target version and date.

1. Clean up on your current version. Take the latest patch and clear deprecation warnings. On Kotlin 2.3, move to 2.4 in its own PR first, since Boot 4.2 manages 2.4.21 (my Kotlin 2.4 notes). Run the properties migrator once, as in the Boot 4 path. Write tests for your quiet rows that assert the behavior you rely on today. They pass now, keep passing in stage 2 because of the pins, and show what changes when you remove a pin in stage 6. (The sample’s canaries are the other way round: they assert 4.2’s behavior, so they fail on 4.1 by design.) Ships when: zero deprecation warnings, and those tests pass on the old version.

2. Bump Boot with the old behavior pinned. Bump, fix the loud breaks, and pin what you rely on from the quiet table:

# Absolute redirect Locations, as in 4.1, until clients are checked
server.tomcat.servlet.use-relative-redirects=false
# The active-request timers your dashboards read
management.metrics.observations.include-active-long-task-timer=true
# Only if your proxy sets X-Forwarded-Prefix and you rely on it (Tomcat needs the framework strategy)
server.request.header.forwarded.strategy=framework
server.request.header.forwarded.use-prefix=true

When you bump to 4.2, rename server.forward-headers-strategy to server.request.header.forwarded.strategy in the same PR, not earlier: 4.1 ignores the new name, and 4.2 won’t start with both. The value native is now web-server. The framework strategy trusts forwarded headers from any client, so make sure your edge proxy strips inbound Forwarded and X-Forwarded-* headers. Keep the noble builder, so the OS doesn’t change too. Redis master/replica isn’t a pin: decide which database you want. Ships when: error rate and p95 latency match the old build in staging and in a canary deploy, and the startup median is recorded as the payoff baseline.

3. Move the base image, with both builder and runImage pinned, or neither. Ships when: scanner findings are reviewed, the shell matches your decision, and startup and memory match stage 2.

4. Turn on the registry build cache for ephemeral runners. Ships when: warm and cold build times are measured.

5. Telemetry opt-ins, one per deploy. Common OTLP config first, then OpenTelemetry conventions with dashboards migrated in the same change. Ships when: every panel and alert still has data, and trace IDs still reach the logs.

6. Remove the pins, one decision at a time. Ships when: the pin block is empty, or every line left says why it stays.

7. RestTemplate to RestClient, client by client. Ships when: the grep count reaches zero, well before 4.4.0.

Roll back newest-first, and keep the last pre-upgrade build deployable for a while. Splitting the OS change from the Boot bump keeps each rollback clean.


✅ How You Know You’re Done Link to heading

  • Every service on 4.1 or 4.2, latest patch, with zero deprecation warnings beyond counted RestTemplate ones.
  • Every loud item is fixed, and every quiet item that applies has a test or a dashboard check.
  • No server.forward-headers-strategy, no useTestClasspath, and no spring-boot-starter-amqp where you meant RabbitMQ.
  • At least one live-server test per service.
  • Image builds pin both builder and runImage, or neither, on purpose.
  • Startup median, error rate and p95 compared before and after, and written down.
  • Every remaining pin has a reason.

☕ Conclusion Link to heading

Getting to 4.2 is cheap in code and expensive in behavior. The work is tests at the HTTP edge, a careful base-image change, and deploys small enough to roll back.

Move for the support window and the operational wins, and measure them. Put the red mug next to the staging dashboard for stage 2: that’s where the quiet changes show up.


Sources


Related Posts