Spring Boot – Create REST API Basic (Hello World)

By | September 25, 2018

Hey guys 👋In the last tutorial we have been already learn about create new spring boot application. In this tutorial, we will learn how to create REST API basic in spring boot.

Spring Boot – Create REST API Basic (Hello World)

First, create new package or folder with name “controller”.

Second, create new java class with name “HelloController.java”. After that copy and paste source code below to your new class:

@GetMapping(value = "/hello-world")
 public ResponseEntity showHelloToPeople(){

   String hello = "Hello world!";

   return new ResponseEntity<>(hello, HttpStatus.OK);

Third, run your application and open your browser (chrome, opera, safari, IE 11) then goto “http://localhost:8080/spring-boot/hello-world”.

Spring Boot - Create REST API Basic (Hello World)

Voillaa.. you just create a basic REST API.

On the next spring boot tutorial we will learn about how to connect to database MongoDB. Don’t forget, If you have a question, please feel free to share your thoughts in the comments below. Thank you 🙂


One thought on “Spring Boot – Create REST API Basic (Hello World)

  1. Pingback: Spring Boot - Create New Application ~ Cimblo.com

Leave a Reply

Your email address will not be published. Required fields are marked *