Spring Boot Project from Scratch (Java, Gradle, Jar)

This tutorial will cover step by step process of create Spring Boot project from Scratch.

What are you going to learn from here

  • Create project from Spring Initializr

  • Spring Web Dependency

  • How to open project from existing source.

  • Create Controller and a method for show Bismillah.

How to complete this guide

Step by Step Process

Please Follow the Step by Step Instruction

Initialization Stage

  • Go to Spring Initializr

  • Then select below configuration (You may select of your choice)

    • Project: Gradle Project

    • Language: Java

    • Spring Boot: 2.3.1 (When I wrote it this was the latest stable version, please select latest one)

    • Project Metadata

      • Group: com.hmtmcse.spring (Your project group name)

      • Artifact: spring-boot (You can choose your one)

      • Name: spring-boot-tutorial (Name of the Project)

      • Description: This is for Spring Boot Step By Step Tutorial. (Put Relevant description)

      • Package name: com.hmtmcse.spring (You can use your own domain name in revers order)

      • Packaging: Jar (Jar for standalone you may choose war if you want to deploy in a container for production)

      • Java: 11 (You can choice by your preference)

  • Dependencies: Click on Add Dependencies and add below

    • Spring Web: For Web MVC & RESTful API

  • From Bottom panel click on Generate, It will start download of a zip file.

spring-initializr

Open project from the zip file stage

  • After download the zip file please extract it.

  • The follow the Open Gradle Project From Source, Otherwise please follow the below video for clear the full process.

Create a controller and see the first view stage

  • Project Root >> src >> main >> java >> select the package and right click on it and create a file called FirstController

  • Write the below codes there

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class FirstController {

    @GetMapping("/")
    @ResponseBody
    public String bismillah(){
        return "<h1>Bismillah</h1>";
    }

}

Spring Boot Project from Scratch YouTube Video Tutorial