Class RestTemplate

All Implemented Interfaces:
RestOperations

public class RestTemplate extends InterceptingHttpAccessor implements RestOperations
Synchronous client to perform HTTP requests, exposing a simple, template method API over underlying HTTP client libraries such as the JDK HttpURLConnection, Apache HttpComponents, and others. RestTemplate offers templates for common scenarios by HTTP method, in addition to the generalized exchange and execute methods that support less frequent cases.

RestTemplate is typically used as a shared component. However, its configuration does not support concurrent modification, and as such its configuration is typically prepared on startup. If necessary, you can create multiple, differently configured RestTemplate instances on startup. Such instances may use the same underlying ClientHttpRequestFactory if they need to share HTTP client resources.

NOTE: As of 6.1, RestClient offers a more modern API for synchronous HTTP access. For asynchronous and streaming scenarios, consider the reactive WebClient.

Since:
3.0
Author:
Arjen Poutsma, Brian Clozel, Roy Clarkson, Juergen Hoeller, Sam Brannen, Sebastien Deleuze
See Also: