We are currently utilizing numerous microservices that employ Spring RestTemplate.
Considering the Spring - 5.3.5 documentation, it's stated that this class is now in maintenance mode as of 5.0, indicating that only minor changes and bug fixes will be considered going forward. It's suggested that we transition to using the org.springframework.web.reactive.client.WebClient, which boasts a more current API and supports synchronous, asynchronous, and streaming scenarios.
However, when examining the Spring 6.1 documentation, RestTemplate isn't mentioned. This leads to several questions regarding the future of RestTemplate:
- Is there a chance that RestTemplate will be discontinued in the future?
- Is the plan to keep RestTemplate in maintenance mode?
- Are there plans to improve RestTemplate with new features in the future?
- Given the circumstances, would migrating to RestClient be advised? If so, are there any plans to automate this transition from RestTemplate to RestClient using OpenRewrite recipes?
Ref: https://docs.spring.io/spring-framework/docs/5.3.5/javadoc-api/org/springframework/web/client/RestTemplate.html https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html
Comment From: poutsma
Next time, please consider using a different channel for asking questions such as these, such as StackOverflow. This tracker is meant to track issues.
However, when examining the Spring 6.1 documentation, RestTemplate isn't mentioned.
I am not sure what gave you that impression, because there is a section on RestTemplate
in the reference guide, including a migration guide from RestTemplate
to RestClient
.
- Is there a chance that RestTemplate will be discontinued in the future?
It is hard to give full-fledged predictions for a framework with a history of over 20 years. Will RestTemplate
be in Spring Framework in another 20 years time? Probably not. Will it be in Spring Framework 7.x? For sure.
- Is the plan to keep RestTemplate in maintenance mode?
The "maintenance mode" note on RestTemplate
caused confusion among many of our users, who thought it meant the same as being deprecated. That's why in version 6.1, we removed it.
- Are there plans to improve RestTemplate with new features in the future?
Not at this time.
- Given the circumstances, would migrating to RestClient be advised? If so, are there any plans to automate this transition from RestTemplate to RestClient using OpenRewrite recipes?
I'll refer you to the aforementioned migration guide.
Comment From: poutsma
I have added a note to the RestTemplate
Javadoc that clarifies the current situation, see b16f379788b8b56e4a744e5645f8f524f343da57.