Class RestTemplate

All Implemented Interfaces:

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 of 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 the underlying ClientHttpRequestFactory if they need to share HTTP client resources.

NOTE: As of 5.0 this class is in maintenance mode, with only minor requests for changes and bugs to be accepted going forward. Please, consider using the org.springframework.web.reactive.client.WebClient which has a more modern API and supports sync, async, and streaming scenarios.

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