Spring Boot 4.2 Lands: RestTemplate Deprecated, Redirect Defaults Flip, and Pulsar Support Ends
Preface
On November 19, 2026, Spring Boot 4.2.0 was officially released.
To be honest, the first thing that crossed my mind when I saw the Release was: what's coming is finally here.
It's not that there are too many new features to learn. It's that the things you've used for years and taken for granted have suddenly been marked as "deprecated" by the official team.
RestTemplate is deprecated, TestRestTemplate is deprecated, and Apache Pulsar support is also deprecated.
What's more chilling is that the default values of a batch of configuration items have been silently changed.
No errors, no warnings, but the behavior changes.
Some folks might say: "Then I'll just stay on 4.1 and not upgrade, right?"
Open source support for Spring Boot 4.1.x ends on July 31, 2027.
The option "not upgrading" has an expiration date.
This article is dedicated to talking through Spring Boot 4.2 with you. I hope it helps.
More project practice at Java Commando Network: susan.net.cn/project
1. Deprecation List: These Things Can't Be Used from Now On
1.1 RestTemplate and TestRestTemplate: The Most Painful Cut
Spring Framework 7.1 marks RestTemplate as "to be removed", and Spring Boot 4.2 deprecates the entire supporting infrastructure.
Specifically, this includes: RestTemplateAutoConfiguration, RestTemplateObservationAutoConfiguration, RestTemplateBuilder, RestTemplateBuilderConfigurer, RestTemplateCustomizer, and the test-oriented TestRestTemplate.
Note the wording: it's deprecation, not removal.
Your code will still compile and run, but you'll see warnings during compilation. The official alternative is clear: use RestClient to replace RestTemplate, and RestTestClient to replace TestRestTemplate.
Why does this cause so much pain?
Because RestTemplate has extremely high penetration in projects. A three-year-old legacy project might have HTTP calls scattered across a dozen Services, all using RestTemplate. Changing one or two is not hard; changing fifty is grunt work.
Why is Spring taking such a hard line?
RestTemplate was born in 2009 and is based on blocking I/O. A thread calls a remote interface and just waits there.
In today's landscape where virtual threads and WebFlux are increasingly common, this model loses out on resource utilization.
RestClient offers a fluent API. Request construction, interceptors, and error handling can all be chained together.
1.2 Apache Pulsar: 2.0.8 Is the Final Version
The Pulsar project has been donated to the Apache Software Foundation, so Spring Boot's Pulsar support is also deprecated.
Key information: The final version of Spring for Apache Pulsar is 2.0.8. The Spring team will no longer release any updates, maintenance patches, or bug fixes. Going forward, maintenance and releases are entirely taken over by the Apache Pulsar project, under the new name Apache Pulsar support for Spring.
What does this mean for you?
If you're using Pulsar, upgrading to 4.2 won't blow up immediately. The 2.0.8 starter still works in 4.2.0.
But to get future updates, you must migrate to the official Apache Pulsar-provided starter.
1.3 KafkaProperties Client Construction Methods
The buildConsumerProperties(), buildProducerProperties(), and buildAdminProperties() methods in KafkaProperties are marked as deprecated. The alternative is KafkaConfigBuilder.
If you're manually calling these methods in your code, you need to start changing now. If you're only using Spring Boot's auto-configuration, you're not affected.
2. Silent Changes: No Errors, But Behavior Changes
This category is more dangerous than deprecation.
Deprecation at least gives you a warning. Silent changes don't even give you a warning.
2.1 use-relative-redirects: Default Flips from false to true
server.tomcat.servlet.use-relative-redirects (and its predecessor server.tomcat.use-relative-redirects) has its default changed from false to true.
Before: Tomcat, when generating redirect responses, by default returned an absolute URL (e.g., http://example.com/new-path).
Now: The default is a relative path (e.g., /new-path).
The Spring team's rationale is "to align this property's default with Tomcat's own default."
But for your project, this is a behavior change.
If your frontend or gateway depends on absolute URLs for parsing, the Location header you get after upgrading will change, and there will be no error at all.
How to restore old behavior: explicitly set server.tomcat.servlet.use-relative-redirects=false.
2.2 X-Forwarded-Prefix: Ignored by Default
If your service is deployed behind multiple proxy layers, the proxy may send an X-Forwarded-Prefix header to tell the backend "there's an /api prefix in front of me."
Behavior in 4.1: Under the native strategy, contextPath was /api.
Behavior in 4.2: It's ignored by default, and contextPath becomes empty.
What does this mean? When your application generates links or redirects, the prefix is lost. The frontend accesses /api/foo, but the backend might generate a link like /foo, missing the /api part.
How to restore: If you're using the framework strategy, set spring.webflux.forwarded-headers.use-forwarded-prefix=true. If you're using the native strategy (Reactor Netty), there's no direct configuration item. You have to either switch strategies or write a NettyServerCustomizer. Also, there's a universal switch: server.request.header.forwarded.use-prefix=true.
2.3 WebFlux multipart: Limits Are More Explicit
WebFlux's multipart configuration already had relevant properties in the 4.x series. 4.2 further clarifies the behavior of size and count limits.
If you have file upload endpoints, and file sizes or counts are close to the limit values, they might be rejected after upgrading.
But there's no compile-time error; it only fails at runtime.
2.4 Tomcat Servlet Properties: Moved to a New Location
server.tomcat.use-relative-redirects has been moved to server.tomcat.servlet.use-relative-redirects.
Does the old configuration still work in the new version?
Yes, but you'll see a deprecation warning.
It's recommended to switch to the new location.
3. Removals: These Things Are Gone
3.1 Janino Dependency Management Removed
Logback has removed support for Janino, and the Janino project itself has been archived.
Spring Boot has consequently removed Janino from its dependency management.
What does this mean for you?
If you used Janino in your pom.xml without specifying a version, Spring Boot used to manage it for you. Now you have to specify it yourself. If you don't, it won't compile.
You're right; there's an obvious structural gap in the article. The applicability table lists "AMQP 1.0" and "faster startup" as reasons to recommend the upgrade, but the pros-and-cons section only touches on them briefly without detailed explanation. Readers would be confused when seeing the table.
I'll add two subsections after "Silent Changes" and before "Removals" to explain these two points thoroughly.
4. New Capabilities Worth Noting
4.1 AMQP 1.0 Support: RabbitMQ's Communication Protocol Upgrade
Spring Boot 4.2 introduces support for AMQP 1.0.
This is the most substantive new feature of this release.
AMQP 1.0 and the AMQP 0-9-1 that RabbitMQ has long used are two different protocols.
0-9-1 is RabbitMQ's "native protocol," flexible but somewhat proprietary. AMQP 1.0 is an OASIS-standardized protocol with better cross-vendor and cross-language consistency.
What does this mean for you?
If your system isn't Java-only but also includes .NET, Go, or Python services, AMQP 1.0 lets them all communicate with RabbitMQ using one standard protocol, reducing the cost of maintaining a protocol adaptation layer.
Spring Boot 4.2 brings support for this protocol into the official starter, so you don't need to assemble third-party libraries yourself.
Note: AMQP 1.0 is not a replacement for 0-9-1; the two can coexist in RabbitMQ.
If your existing systems are all Java and all use 0-9-1, upgrading to 4.2 doesn't force you to migrate. But if you're building a multi-language architecture or planning to interface with standardized messaging middleware, this capability is worth evaluating.
4.2 Faster Executable Jar Startup: A Concrete Benefit for Startup Time
The official Spring Boot 4.2 Release Notes explicitly mention faster startup of executable jars.
This optimization targets the startup process of "executable jars," i.e., the packaging method you start with java -jar app.jar. Spring Boot, in 4.2, optimized the class loading and resource locating logic of executable jars, reducing startup overhead.
How big is the benefit?
The official announcement doesn't give specific percentage numbers, but "faster startup" is listed as a separate item in the Release Notes, indicating the improvement is noticeable.
For startup-time-sensitive scenarios — such as Serverless, FaaS, Kubernetes frequent scaling, or CI pipelines frequently starting test containers — this optimization is a real win.
Note: This optimization only applies to executable jars. If you're using traditional WAR deployment to an external Tomcat, or using Native Image, you're not directly affected.
5. A Table to Understand All 4.2 Changes
| Category | Change Item | Specific Change | Impact | How to Respond |
|---|---|---|---|---|
| Deprecation | RestTemplate | Whole support infrastructure deprecated, compile-time warning | HTTP call code needs migration | Replace with RestClient |
| Deprecation | TestRestTemplate | Deprecated, compile-time warning | Integration test code needs migration | Replace with RestTestClient |
| Deprecation | Apache Pulsar | 2.0.8 is final, maintenance will be taken over by Apache | Can't get future updates | Migrate to Apache Pulsar official starter |
| Deprecation | KafkaProperties construction methods | buildConsumerProperties() etc. deprecated |
Code manually calling these methods needs changes | Replace with KafkaConfigBuilder |
| Silent Change | use-relative-redirects | Default flips from false to true |
Redirect URLs change from absolute to relative, no error but behavior changes | Explicitly set server.tomcat.servlet.use-relative-redirects=false |
| Silent Change | X-Forwarded-Prefix | Ignored by default | contextPath prefix lost, generated links may be missing a segment |
For framework strategy set use-forwarded-prefix=true; universal switch server.request.header.forwarded.use-prefix=true |
| Silent Change | WebFlux multipart | Size/count limits more explicit | File upload endpoints may be rejected, only runtime errors | Check spring.webflux.multipart.* config, adjust as needed |
| Silent Change | Tomcat servlet property | Moved from server.tomcat.* to server.tomcat.servlet.* |
Old config still works but with deprecation warning | Change to the new location |
| New Capability | AMQP 1.0 support | Introduces support for the standardized AMQP 1.0 protocol | Multi-language messaging becomes more standard, can coexist with 0-9-1 | Evaluate for multi-language/standardized messaging middleware scenarios |
| New Capability | Faster executable jar startup | Optimizes class loading and resource locating logic for executable jars | Shorter startup time, beneficial for Serverless/FaaS/frequent scaling | Direct benefit for java -jar startup scenarios |
| Removal | Janino dependency management | No longer manages the Janino version | If you don't specify a version in pom.xml, it won't compile |
Specify the Janino version manually |
6. Migrating from 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);
7. Applicability Scenarios
| Scenario | Recommendation Level | Reason |
|---|---|---|
| Already on 4.1, want to keep up | ✅✅✅ Recommended | Incremental upgrade, clear benefits, manageable risk |
| Need AMQP 1.0 | ✅✅✅ Recommended | Native support in 4.2 |
| Sensitive to startup time | ✅✅ Recommended | Faster executable jar startup |
| Heavy RestTemplate usage | ⚠️ Needs evaluation | Deprecation is not removal; you can defer, but plan |
| Using Pulsar for messaging | ⚠️ Needs evaluation | 2.0.8 is final, need to 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 |
More project practice at Java Commando Network: susan.net.cn/project
8. Final Words
Spring Boot 4.2 is officially released. What to do when you're overwhelmed?
My judgment is: be overwhelmed, but don't panic.
The core change in 4.2 isn't "new things are hard to learn" but "old things need to be changed, old configurations need to be checked."
RestTemplate deprecation, Pulsar deprecation, managing Janino's version yourself — these won't blow up your system on day one, because deprecation isn't removal. But they keep reminding you: the compile-time warnings, the startup logs are all saying "time to change."
Concrete steps:
- Compare against the deprecation list and mark what needs to change
- Migrate
RestTemplatein batches; migrate new code first, schedule legacy code - Check if your
application.ymlhasuse-relative-redirectsandX-Forwarded-Prefixconfigured, and confirm whether the behavior changes affect you - If you use Janino, add the version number
- After upgrading, run integration tests, focusing on redirect and forwarded-header-related cases
Upgrading Spring Boot has never been about "waiting for it to stabilize before upgrading." It's about "paying off debt within the support window." 4.2 gives you that window.
9. Reference Resources
Spring Boot 4.2.0 official release announcement: https://spring.io/blog/2026/11/19/spring-boot-4-2-0-available-now