Most Spring Boot tutorials stop at "it returns JSON". Real APIs also need input validation, clear error responses and a database that behaves the same on every machine. In this tutorial we will build a small but production-shaped REST API for managing members of a savings scheme, using Spring Boot 3, Java 21 and PostgreSQL running in Docker.
By the end you will have:
A PostgreSQL database started with one command
CRUD endpoints for members
Request validation with clear error messages
A global exception handler that returns consistent JSON errors
Paginated list results
Prerequisites
Java 21
Maven 3.9+
Docker and Docker Compose
curl or any API client
Step 1: Create the project
Go to start.spring.io and choose:
Project: Maven, Language: Java, Spring Boot: the latest 3.x release
Java: 21
Dependencies: Spring Web, Spring Data JPA, Validation, PostgreSQL Driver
Download and unzip the project.…