An in-depth piece exploring building a modular event-driven microservices architecture, using Spring and Orkes Conductor for orchestration:
REST with Spring Tutorial
Last updated: September 28, 2023
Building a REST API is not a trivial task – from the high-level RESTful constraints down to the nitty-gritty of making everything work and work well.
Spring has made REST a first-class citizen and the platform has been maturing in leaps and bounds.
With this guide, my aim is to organize the mountains of information that are available on the subject and guide you through properly building an API.
The guide starts with the basics – bootstrapping the REST API, the Spring MVC Configuration, and basic customization.
It then dives into the more advanced areas of REST – such as error handling, pagination, documenting, and testing the API.
Prerequisites
REST API Basics
- The Spring @Controller and @RestController Annotations
- Spring's RequestBody and ResponseBody Annotations
- Spring @PathVariable Annotation (popular)
- Spring @RequestParam Annotation (popular)
- Spring @RequestMapping
- Using Spring @ResponseStatus to Set HTTP Status Code
- Using Spring ResponseEntity to Manipulate the HTTP Response (popular)
- How to Read HTTP Headers in Spring REST Controllers
- Building a REST API
- Entity To DTO Conversion for a Spring REST API
- Error Handling for REST (popular)
REST API Documenting and Versioning
REST API Advanced Topics
Test and Consume the API: Overview
Test and Consume the API: RestTemplate
- The Guide to RestTemplate
- RestTemplate Post Request with JSON
- RestTemplate with Basic Authentication
- Get and Post Lists of Objects with RestTemplate
- Configure a RestTemplate with RestTemplateBuilder
- Spring RestTemplate Error Handling
- Uploading MultipartFile with Spring RestTemplate
- Spring RestTemplate Request/Response Logging
Test and Consume the API: WebClient
Other Spring Tutorials
- Spring Boot Tutorial (Series) Get started with Spring Boot and learn how to customize a Spring Boot application
- Spring Persistence Tutorial (Series) Learn how to work with Spring Data JPA and other Spring persistence technologies
- Spring Security OAuth2 Guides (popular) (Series) Learn how to secure a REST API using Spring OAuth2 support