How to create simple rest apis with springboot

Aditya Sridhar on November 05, 2018

This post was originally published in As a part of this article you will be building 2 simple REST apis Using Springboot. This... [Read Full]
markdown guide

Looks good, I would recommend updating Spring Boot to 2.1.0. Besides that, don't use 'Test' in such tutorials. Keep them realistic and use something like "getAll()" or something.

Why don't you use ResponseEntity<>?

And another good improvement would be to explain how a request flows from the browser of the user through the (Rest)Controller to the Service and into the Repository if needed.


Thank you for the feedback :)

Will use proper naming conventions in the next one :D

I could have used response entity as well. Maybe will use that in the next article.

Planning to write one more article for the flow from controller to service to repository. That's the reason I did not include it here. Wanted to separate them out since having them in one article makes the article long and readers may feel its too much information in one article.


I prefer to use ResponseEntity because it is Spring itself as the tutorial focuses on Spring.

Good luck!


Always good to see some Java love around here 😊

Two recommendations:

  • Use @GetMapping and @PostMapping for better readability
  • use Lombok getters/setter for the entities



Thank you for the suggestions :)

Will read the article :)


BTW, Lombok is also available at ! Just type it in the dependencies search box.


Great timing. I was just experimenting with Spring Boot.
Any tips on connecting a database to store and retrieve model objects?


If you need a fully fledged ORM, you can use Spring Data JPA with Hibernate which is really easy to get started quickly and works very well with Spring Boot. I use a library called JOOQ (Java Object Oriented Query) which allows you to write type safe SQL and provides you with code generation features. It also gives you basic CRUD. Also I use flyway for migrations.


Just have a look at the official guides.

There is one for relational database access ( and for others as well.


Hibernate is a good option.

You could also use spring JDBC. Explore both and check :)

code of conduct - report abuse