Skip to main content

REST tutorial introduction


In this tutorial series, we are going to study RESTful services with Spring.

We are going to build a TodoApp in this series since it is one of the easiest way to touch the technical stack.

You can find the complete source code here Todoapp

For the simplicity i'm going split tutorial into smaller parts.
  1. Section 1: CRUD
  2. Section 2: Error handling
  3. Section 3: Security
  4. Section 4: User interface
  5. Section 5 : Miscellaneous


  • Create a RESTful service using Java tech stack.

What you need

  • Java 8
  • Gradle 4
  • IDE


REST stands for REpresentational State Transfer. It is an architectural style rather than a strict protocol. Not a standard but a set of constraints, such as being stateless, having a client/server relationship, and a uniform interface.

Spring Framework

The Spring Framework is an application framework and inversion of control container for the Java platform.

Spring Boot

Spring boot is a Spring based production-ready project initializer which create Spring-powered, production-grade applications and services with absolute minimum fuss.

HTTP methods


HTTP Status Codes

HTTP codeStatus
204Deleted (No content)
400Bad Request
404Not found
405Method not allowed

Define our REST API

First of all let's define our API.
  • return all Todo entries: '/todos' : GET request 
  • create a new Todo entry : '/todos' : POST request 
  • delete a Todo : '/todos/{id}' : DELETE request 
  • update a Todo : '/todos/{id} : PUT request 
  • view a Todo: '/todos/{id}' : GET request

Create the starter project

  • Go to
  • Enter Group and Artifact 
  • Select Web, H2, JPA and Lombok dependencies 
  • Click Generate Project to generate and download the project

Modify the starter

  • Create HelloController and add following,

  • Go to project location and run the project
         gradle bootrun

Congratulations!!! you just created your first service ;)


Post a Comment