Difficulty: Beginner
Estimated Time: 15 minutes

Do you want to set up your first Spring Boot project? Then, you're at the right place!

In this scenario, we'll learn how to:

  • Create a Spring Boot project for a simple REST server
  • Create some service endpoints
  • Pass parameters to an endpoint
  • Create a REST endpoint that uses Cassandra

This scenario is a brief introduction to Spring Boot so you can see how to create an initial project.

ver 0.001

This scenario introduced Spring Boot and showed how to set up a simple Spring Boot project.

In this scenario, we learned how to:

  • Create a Spring Boot project for a simple REST server
  • Create some service endpoints
  • Pass parameters to an endpoint
  • Create a REST endpoint that uses Cassandra

We have only just begun to scratch the surface of Spring Boot. We didn't use a lot of the spring boot features like Spring Data or Spring Rest, etc. The next scenario in this series explores more of the Spring Boot projects.

Build a Spring Boot REST Service

Step 1 of 6

Set up the server

In this step, we are going to set up the web server. Normally, you would start by visiting Spring Initializr and generating a project zip file. We have already done that for you, so all we need to do now is unzip the file.

unzip demo.zip

Here's the main class for the service.

Open demo/src/main/java/com/example/demo/DemoApplication.java

Let's run the project.

cd /root/demo
mvn spring-boot:run

Wait for the service to fully initialize (you'll see the log output stop scrolling when the service is ready).

We'll leave the service running in this terminal and open a second tab (just click on the command below to open the second terminal) where we will access the service.

curl 127.0.0.1:8080/ | jq

You'll see output like this:

{
  "timestamp": "2020-08-12T17:15:59.313+00:00",
  "status": 404,
  "error": "Not Found",
  "message": "",
  "path": "/"
}

We see from the 404 that the service exists, but doesn't handle requests yet. We'll fix that in the next few steps.

Excellent! We have a running HTTP service!