RestTemplate

RestTemplate is a synchronous client for making HTTP requests. It is the original REST client for Spring that provides a simple API with templates and methods on top of the underlying HTTP client libraries.

Starting from version 5.0, RestTemplate is in maintenance mode, and in the future only minor requests for changes and bugs will be accepted. Please consider using WebClient, which offers a more modern API and supports synchronous, asynchronous, and streaming scenarios.

WebClient

WebClient is a non-blocking, reactive client for making HTTP requests. It was introduced in version 5.0 and is a modern alternative to RestTemplate that provides support for both synchronous, asynchronous, and streaming scenarios.

Unlike RestTemplate, WebClient supports:

  • Non-blocking I/O.

  • Feedback to the Reactive Streams specification.

  • High parallelism with fewer hardware resources.

  • A fluid, functional-style API that takes advantage of Java 8 lambda expressions.

  • Synchronous and asynchronous interaction.

  • Stream to a server or stream from a server.