Hackforge Academy

Category: java

how to create spring boot and run the app

Published on 01 Apr 2026

Explanation

Step 1: Install Required Tools πŸ› οΈ β€” Before creating a Spring Boot app, make sure Java (JDK 17+ recommended), Maven (or Gradle), and an IDE like IntelliJ IDEA or VS Code are installed.

Code:

java -version
mvn -version

Explanation

Step 2: Create a Spring Boot Project πŸš€ β€” Use Spring Initializr (https://start.spring.io/) and select Project: Maven, Language: Java, Spring Boot Version: Latest stable, Dependencies: Spring Web. Download and extract the project.

Code:

Group: com.example
Artifact: demo
Dependencies: Spring Web

Explanation

Step 3: Main Application Class ▢️ β€” This is the entry point of your Spring Boot application. The @SpringBootApplication annotation enables auto-configuration and component scanning.

Code:

package com.example.demo;

import org.springframework.boot.
SpringApplication;
import org.springframework.boot.
autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
 SpringApplication.run(
DemoApplication.class, args);
    }
}

Explanation

Step 4: Create a REST Controller 🌐 β€” Add a simple controller class to handle HTTP requests and return a response.

Code:

package com.example.demo;

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

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

@RestController
public class HelloController {

    @GetMapping("/hello")
    public String sayHello() {
        return "Hello Spring Boot!";
    }
}

Explanation

Step 5: Run the Application ▢️ β€” Open terminal in the project folder and run the Spring Boot app using Maven.

Code:

mvn spring-boot:run

Explanation

Step 6: Test the Application βœ… β€” Open a browser and visit the endpoint below. You should see the response from your controller.

Code:

http://localhost:8080/hello

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community