REST API: Java Spring Boot and MongoDB

Creating a RESTful web service using the Spring Boot framework and MongoDB

Thomas Gleason
7 min readMay 19, 2018

Why Spring Boot?

The Java Spring Boot framework provides a powerful set of tools for web development on both the front-end and back-end. It has built-in configuration for security and database access, as well as simple request mappings. This framework is highly configurable and makes web development extremely simple.

Why MongoDB?

Mongo is quickly growing in popularity among NoSQL databases. Read more about NoSQL and its benefits here. MongoDB, specifically, is perfect for developing a REST API with Spring Boot for a couple of key reasons:

  • Data is stored in MongoDB as JSON
  • Spring Boot provides a powerful MongoDB connector

Tools Used in this Tutorial

1. Java
2. Spring Boot
3. Maven
4. MongoDB
5. Postman

Step 1: Creating a Database

This tutorial assumes that you already have an accessible instance of MongoDB that you can connect to. For more information on getting started with MongoDB, visit their online tutorial.

Let us start by creating a test database. I will call mine “rest_tutorial” using the following command in…

--

--