How to create Spring Boot Application 2021

Hi Devs,

Today I am going to show you how to create a simple spring boot project from scratch.

Go to spring initializer to generate a spring boot project.

Spring Initilizer

The pom.xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
      <relativePath/> <!-- lookup parent from repository -->
   <description>simple project for Spring Boot</description>



</project> file

Go to the file and set the server port, by default the port is 8080. You can change it in the properties file.


Create a controller

GO the the main folder and create a package name it controller, its the nameing conveniton to create the controllers in the controller package.

My controller name is

package com.codesnipeet.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

public class HelloWorldController {
    public String displayMessage(){
        return "Hello spring boot World!";

Run the project

Go to browser and enter the end-point and see the magic:



Hope It helps: