Photo by Sarah Dorweiler on Unsplash

Spring 6 and Declarative HTTP Clients

How to Pare Down Your HTTP Client Code

Craig Walls
2 min readFeb 9, 2023

--

https://pragprog.com/newsletter/

Spring introduced RestTemplate in Spring 3.0 as a convenient, template-based component for consuming HTTP services in Spring applications. It stood out as the best way to create HTTP clients in Spring until Spring 5.0 introduced WebClient, a reactive and fluent alternative to RestTemplate.

Both RestTemplate and WebClient take away a lot of the heavy lifting that would otherwise be involved in making HTTP requests and binding the responses to application domain types.

But what if you could eliminate nearly all of the logic involved in making an HTTP request and reduce your HTTP client code down to little more than an interface that’s annotated with request details? That’s what I demonstrate in this video: how to use Spring 6’s support for declarative HTTP clients.

If you enjoyed this video, you might also enjoy Build Talking Apps for Alexa, my book on creating voice experiences for Amazon Alexa:

If you’d like to participate in conversations about the book and find a promo code for a 35 percent discount, visit the book’s page on DevTalk:

--

--