mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Deprecate RestTemplate and related types
As announced in "the state of HTTP clients in Spring" blog post (https://spring.io/blog/2025/09/30/the-state-of-http-clients-in-spring), the deprecation timeline for `RestTemplate` was announced last November and docs were updated accordingly. This commit `@Deprecate` `RestTemplate` and related types for removal to send a stronger signal to our community. The actual removal is scheduled for Spring Framework 8.0 (not yet scheduled). Closes gh-36574
This commit is contained in:
+13
-1
@@ -152,7 +152,10 @@ public final class MockRestServiceServer {
|
||||
* Return a builder for a {@code MockRestServiceServer} that should be used
|
||||
* to reply to the given {@code RestTemplate}.
|
||||
* @since 4.3
|
||||
* @deprecated as of 7.1 in favor of {@link #bindTo(RestClient.Builder)}.
|
||||
*/
|
||||
@Deprecated(since = "7.1", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public static MockRestServiceServerBuilder bindTo(RestTemplate restTemplate) {
|
||||
return new RestTemplateMockRestServiceServerBuilder(restTemplate);
|
||||
}
|
||||
@@ -161,7 +164,10 @@ public final class MockRestServiceServer {
|
||||
* Return a builder for a {@code MockRestServiceServer} that should be used
|
||||
* to reply to the {@code RestTemplate} for the given {@code RestGatewaySupport}.
|
||||
* @since 4.3
|
||||
* @deprecated as of 7.1 in favor of {@link #bindTo(RestClient.Builder)}.
|
||||
*/
|
||||
@Deprecated(since = "7.1", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public static MockRestServiceServerBuilder bindTo(RestGatewaySupport restGatewaySupport) {
|
||||
Assert.notNull(restGatewaySupport, "'restGatewaySupport' must not be null");
|
||||
return new RestTemplateMockRestServiceServerBuilder(restGatewaySupport.getRestTemplate());
|
||||
@@ -182,7 +188,10 @@ public final class MockRestServiceServer {
|
||||
* A shortcut for {@code bindTo(restTemplate).build()}.
|
||||
* @param restTemplate the RestTemplate to set up for mock testing
|
||||
* @return the mock server
|
||||
* @deprecated as of 7.1 in favor of {@link #bindTo(RestClient.Builder)}.
|
||||
*/
|
||||
@Deprecated(since = "7.1", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public static MockRestServiceServer createServer(RestTemplate restTemplate) {
|
||||
return bindTo(restTemplate).build();
|
||||
}
|
||||
@@ -191,7 +200,10 @@ public final class MockRestServiceServer {
|
||||
* A shortcut for {@code bindTo(restGateway).build()}.
|
||||
* @param restGateway the REST gateway to set up for mock testing
|
||||
* @return the mock server
|
||||
* @deprecated as of 7.1 in favor of {@link #bindTo(RestClient.Builder)}.
|
||||
*/
|
||||
@Deprecated(since = "7.1", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public static MockRestServiceServer createServer(RestGatewaySupport restGateway) {
|
||||
return bindTo(restGateway).build();
|
||||
}
|
||||
@@ -300,7 +312,7 @@ public final class MockRestServiceServer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static class RestTemplateMockRestServiceServerBuilder extends AbstractMockRestServiceServerBuilder {
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@SpringJUnitWebConfig
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
class MockMvcClientHttpRequestFactoryTests {
|
||||
|
||||
private final RestTemplate template;
|
||||
|
||||
Reference in New Issue
Block a user