Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Spring Boot 4.2 Released: Deprecations, Silent Changes & Migration Guide

Spring Boot 4.2 Released: Deprecations, Silent Changes & Migration Guide

Spring Boot 4.2 introduces major deprecations including RestTemplate and Apache Pulsar support, silent configuration changes like default redirect behavior and forwarded prefix handling, removal of Janino dependency management, and new features such as AMQP 1.0 support and faster executable JAR startup, with detailed migration guidance for upgrading applications.

On November 19, 2026, Spring Boot 4.2.0 was officially released. The release brings significant deprecations, silent configuration changes, and removals that affect existing applications, along with new features like AMQP 1.0 support and faster executable JAR startup.

Spring Boot 4.2 release announcement
Spring Boot 4.2 release announcement

Deprecations: What You Can No Longer Use

1.1 RestTemplate and TestRestTemplate: The Most Painful Cut

Spring Framework 7.1 marked RestTemplate as "scheduled for removal," and Spring Boot 4.2 deprecates the entire support infrastructure. This includes RestTemplateAutoConfiguration, RestTemplateObservationAutoConfiguration, RestTemplateBuilder, RestTemplateBuilderConfigurer, RestTemplateCustomizer, and the test utility TestRestTemplate.

Note the wording: these are deprecated, not removed. Your code still compiles and runs, but compilation produces warnings. The official replacement is clear: use RestClient instead of RestTemplate, and RestTestClient instead of TestRestTemplate.

Why this hurts: RestTemplate is pervasive in projects. A three-year-old application may have HTTP calls scattered across dozens of services, all using RestTemplate. Changing one or two is easy; changing fifty is grunt work.

Why Spring made this move: RestTemplate dates from 2009 and is based on blocking I/O — a thread blocks while waiting for a remote call. In an era of virtual threads and WebFlux, that model wastes resources. RestClient offers a fluent API where request building, interceptors, and error handling can be chained.

1.2 Apache Pulsar: 2.0.8 Is the Final Version

The Pulsar project was donated to the Apache Software Foundation, so Spring Boot's Pulsar support is also deprecated.

Key detail: Spring for Apache Pulsar's final version is 2.0.8 . The Spring team will no longer release updates, maintenance patches, or bug fixes. Future maintenance and releases are entirely handled by the Apache Pulsar project under the new name Apache Pulsar support for Spring .

What this means for you: Upgrading to 4.2 won't break immediately — the 2.0.8 starter remains usable in 4.2.0. But to receive future updates you must migrate to the Apache Pulsar official starter.

1.3 KafkaProperties Client Builder Methods

KafkaProperties

methods buildConsumerProperties(), buildProducerProperties(), and buildAdminProperties() are deprecated. The replacement is KafkaConfigBuilder. If you manually call these methods in code, you must start migrating now. If you rely solely on Spring Boot's auto-configuration, you are unaffected.

Silent Changes: No Errors, But Behavior Changed

These changes are more dangerous than deprecations because they produce no warnings.

2.1 use-relative-redirects: Default Flipped from false to true

The property server.tomcat.servlet.use-relative-redirects (and its predecessor server.tomcat.use-relative-redirects) now defaults to true instead of false.

Before: Tomcat generated redirect responses with absolute URLs (e.g., http://example.com/new-path).

Now: Default redirects use relative paths (e.g., /new-path).

Spring's rationale is to align with Tomcat's own default. However, if your frontend or gateway depends on absolute URLs for parsing, the Location header will change silently — no error thrown.

How to restore old behavior: Explicitly set server.tomcat.servlet.use-relative-redirects=false.

2.2 X-Forwarded-Prefix: Now Ignored by Default

When your service sits behind multiple proxies, a proxy may send an X-Forwarded-Prefix header (e.g., /api) to indicate a path prefix.

4.1 behavior (native strategy): contextPath became /api.

4.2 behavior: The header is ignored by default , so contextPath becomes empty.

Impact: Your application generates links or redirects without the prefix. A request to /api/foo might produce a link to /foo, losing the /api segment.

How to restore: For the framework strategy, set spring.webflux.forwarded-headers.use-forwarded-prefix=true. For the native strategy (Reactor Netty), there is no direct configuration property ; you must switch strategies or write a NettyServerCustomizer. A universal switch is server.request.header.forwarded.use-prefix=true.

2.3 WebFlux Multipart: Limits Enforced More Strictly

WebFlux multipart configuration in the 4.x series already had related properties; 4.2 further clarifies the behavior of size and count limits . If you have file upload endpoints and file sizes or counts approach the limits, upgrades may cause rejections. No compile-time error — only runtime failures.

2.4 Tomcat Servlet Properties: Relocated

server.tomcat.use-relative-redirects

has been moved to server.tomcat.servlet.use-relative-redirects. The old location still works but emits a deprecation warning. Migrate to the new path.

Removals: Gone Completely

3.1 Janino Dependency Management Removed

Logback dropped support for Janino, and the Janino project itself is archived. Spring Boot follows suit by removing Janino dependency management.

Impact: If your pom.xml uses Janino without a version number, Spring Boot previously managed it; now you must declare the version yourself. Omitting the version causes compilation failure.

New Features Worth Noting

4.1 AMQP 1.0 Support: RabbitMQ Protocol Upgrade

Spring Boot 4.2 introduces support for AMQP 1.0 , the most tangible new feature in this release.

AMQP 1.0 and RabbitMQ's long-standing AMQP 0-9-1 are different protocols. 0-9-1 is RabbitMQ's "native" protocol — flexible but proprietary. AMQP 1.0 is an OASIS-standardized protocol with better cross-vendor, cross-language consistency.

What this means for you: If your system includes not only Java but also .NET, Go, or Python services, AMQP 1.0 lets them communicate with RabbitMQ using a single standard protocol, reducing protocol-adapter maintenance. Spring Boot 4.2 bundles this support in the official starter — no more assembling third-party libraries.

Note: AMQP 1.0 is not a drop-in replacement for 0-9-1; both can coexist in RabbitMQ. If your existing stack is pure Java on 0-9-1, upgrading to 4.2 does not force migration. But for multi-language architectures or standardized messaging middleware, this capability is worth evaluating.

4.2 Faster Executable JAR Startup: Real Startup-Time Gains

The official Release Notes explicitly mention faster startup of executable jars .

This optimization targets the executable JAR startup process — i.e., java -jar app.jar. Spring Boot 4.2 optimizes class loading and resource location logic for executable JARs, reducing startup overhead.

How much faster? No specific percentage is given, but "faster startup" appears as a standalone entry in the Release Notes, indicating a perceptible improvement.

For startup-time-sensitive scenarios — Serverless, FaaS, Kubernetes frequent scaling, CI pipelines that spin up test containers — this optimization delivers tangible benefits.

Caveat: This only applies to executable JARs. Traditional WAR deployments to external Tomcat or Native Image builds are not directly affected.

Migration Guide: RestTemplate to RestClient

5.1 GET Request

// RestTemplate
User user = restTemplate.getForObject("/users/{id}", User.class, id);

// RestClient
User user = restClient.get()
    .uri("/users/{id}", id)
    .retrieve()
    .body(User.class);

5.2 POST Request

// RestClient
User created = restClient.post()
    .uri("/users")
    .body(user)
    .retrieve()
    .body(User.class);

5.3 Error Handling

User user = restClient.get()
    .uri("/users/{id}", id)
    .retrieve()
    .onStatus(HttpStatusCode::is4xxClientError, (request, response) -> {
        throw new UserNotFoundException(id);
    })
    .body(User.class);

5.4 Testing: TestRestTemplate → RestTestClient

@Autowired
private RestTestClient restTestClient;

restTestClient.get().uri("/users/1")
    .exchange()
    .expectStatus().isOk()
    .expectBody(User.class);

Applicability Scenarios

Currently on 4.1, want to stay current: ✅✅✅ Recommended — incremental upgrade, clear benefits, manageable risk.

Need AMQP 1.0: ✅✅✅ Recommended — 4.2 provides native support.

Startup-time sensitive: ✅✅ Recommended — executable JAR starts faster.

Heavy RestTemplate usage: ⚠️ Evaluate — deprecation is not removal; can defer migration but must plan.

Using Pulsar for messaging: ⚠️ Evaluate — 2.0.8 is final; must migrate to official starter.

Still on 3.5 or earlier: ❌ Not recommended to jump directly — upgrade to 4.0/4.1 first, then consider 4.2.

Conclusion and Action Items

Spring Boot 4.2 is out — the sky isn't falling, but you can't ignore it.

The core changes aren't "new stuff to learn"; they're "old stuff to replace, old config to audit" . RestTemplate deprecation, Pulsar deprecation, Janino version management — these won't blow up today because deprecation ≠ removal. But they'll keep reminding you via compile-time warnings and startup logs that "it's time to change."

Concrete steps:

Cross-reference the deprecation list and mark what needs changing.

Migrate RestTemplate in batches: new code first, legacy code on a schedule.

Check application.yml for use-relative-redirects and X-Forwarded-Prefix settings; verify whether behavior changes affect you.

If you use Janino, add the version number.

Run integration tests after upgrade, focusing on redirect and forwarded-header scenarios.

Spring Boot upgrades have never been about "wait until it's stable"; they're about "paying down technical debt within the support window." Version 4.2 gives you that window.

Reference

Spring Boot 4.2.0 official release announcement: https://spring.io/blog/2026/11/19/spring-boot-4-2-0-available-now

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

AMQP 1.0Spring Boot 4.2Apache Pulsar migrationexecutable JAR startupJanino removalRestClient migrationRestTemplate deprecationsilent configuration changes

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion