Spring Boot REST API Full Tutorial

<p>This is a complete tutorial of building a REST api with Spring Boot with. You will learn how to :</p> <ol> <li>Create REST APIs</li> <li>Add spring security with jwt authentication &amp; authorization</li> <li>Work with database</li> <li>Add database migration with flyway</li> </ol> <p>The source code of this tutorial is published in git :&nbsp;<a href="https://github.com/farhantanvirtushar/spring-rest-demo" rel="noopener ugc nofollow" target="_blank"><strong>https://github.com/farhantanvirtushar/spring-rest-demo</strong></a></p> <h1>Creating A Spring Boot REST API</h1> <p>Create a spring boot application from&nbsp;<a href="https://start.spring.io/" rel="noopener ugc nofollow" target="_blank"><strong>Spring Initializr</strong></a>&nbsp;with Java version 17. Then add following dependency in&nbsp;<strong>pom.xml</strong>&nbsp;:</p> <pre> &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt; &lt;/dependency&gt;</pre> <p>Create a new package named controllers. Then create a new controller named&nbsp;<strong>HomeController.java</strong>&nbsp;inside our newly created controllers package. Write the following code inside HomeController.java :</p> <pre> package com.example.springrestdemo.controllers; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Controller @RequestMapping(&quot;/rest/home&quot;) public class HomeController { @ResponseBody @RequestMapping(value = &quot;&quot;,method = RequestMethod.GET) public String hello(){ return &quot;hello world&quot;; } }</pre> <p>We have created an api endpoint&nbsp;<strong>&ldquo;/rest/home&rdquo;&nbsp;</strong>for GET request. Now run the application through IDE or through command line with the following command</p> <p><a href="https://medium.com/code-with-farhan/spring-boot-rest-api-full-tutorial-8e577050443b">Click Here</a></p>