I Wanna Rest!
Fundamentals of REST API development with Spring Boot
API development with a REST approach is a widely used standard for providing application functionality over a network. Spring Boot provides robust capabilities for implementing your API, and this blog series will provide a solid introduction to developing and testing a REST API with Spring Boot.
Guide to the Series: REST Fundamentals with Spring Boot
- Introduction (you are here)
- GET All The Things
- Test All the Things
- Send It, POST-Haste
- To PUT Or To PATCH
- Don’t DELETE Me Bro
Throughout this series of blog posts we will gradually develop a modest web API using a Work Order subject domain. This is aligned with my Spring Bike Clinic demo website project, where customers can submit bicycle repair requests. The API we develop will allow the fictional bike shop to manage these work requests.
Database Objects
The data model is shown in the following SQL Script, generated for a MySQL database. Minor changes may be required if you are using a different database platform. We will keep this simple with a single table since relational database design and optimisation are outside the scope of this blog series.
We will utilize the H2 database for local development, with JPA & Hibernate for all database interaction.
You do not need a MySQL instance, H2 will be sufficient.
CREATE DATABASE IF NOT EXISTS demo_rest_fundamentals;
CREATE TABLE IF NOT EXISTS demo_rest_fundamentals.work_orders
(
id CHAR(36) NOT NULL PRIMARY KEY,
created_date_time DATETIME NULL,
bike_description VARCHAR(255) NOT NULL,
work_description VARCHAR(255) NOT NULL
status VARCHAR(50) NOT NULL,
mechanic_notes VARCHAR(255) NULL
);
Source Code
You can either code along in your own Spring Boot project from start.spring.io or just follow along by cloning my GitHub repo associated with this blog series.
$ git clone git@github.com:EricRybarczyk/SpringBikeClinic.API.git
$ cd SpringBikeClinic.API
Let’s Roll
Now we can start to GET All The Things.