From the course: Calling REST APIs with Java

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Calling APIs with Spring

Calling APIs with Spring - Java Tutorial

From the course: Calling REST APIs with Java

Start my 1-month free trial

Calling APIs with Spring

- [Instructor] Most Java developers love the Spring framework. And it provides a few components for interacting with APIs. Here's an example of some code that uses one of those components, the RestTemplate. The RestTemplate was used for years to make calls to APIs, so you might encounter it in preexisting code that uses Spring. However, in Spring 5, the framework developers placed the RestTemplate into maintenance mode and they recommended that we use a new class called the WebClient going forward. Working with the WebClient gives us a major advantage because it supports several interaction styles with APIs. It supports synchronous, asynchronous, and streaming interactions. It's most common to encounter synchronous calls that block the execution of a thread while the client waits for a response after making an API call. In the asynchronous approach, the thread is able to execute other code while waiting for a…

Contents