๐งฐ What Youโll Learn
In this guide, weโll walk through how to:
- Generate a Spring Boot project using Spring Initializr
- Set up and understand the Maven
pom.xml - Write your first simple REST API
- Run the project and test it
๐ ๏ธ Prerequisites
Before you start, make sure you have:
- Java 17 or 21 installed (
java -version) - Maven installed (
mvn -v) - An IDE like IntelliJ IDEA, Eclipse, or VS Code
โก Step 1: Generate a Spring Boot Project
Go to Spring Initializr:
- Project: Maven
- Language: Java
- Spring Boot: 3.5.x (latest stable)
- Group:
com.kscodes.springboot - Artifact:
demo - Name:
demo - Description: Demo project for Spring Boot with Maven
- Packaging: Jar
- Java Version: 17 or 21
- Dependencies:
Click Generate, and a .zip file will be downloaded. Extract and open it in your IDE.

๐ฆ Step 2: Project Structure Overview
demo/
โโโ mvnw
โโโ pom.xml
โโโ src/
โ โโโ main/
โ โ โโโ java/
โ โ โ โโโ com/kscodes/springboot/demo
โ โ โ โโโ DemoApplication.java
โ โ โโโ resources/
โ โ โโโ application.properties
โ โโโ test/
๐งพ Step 3: Maven pom.xml Essentials
Here’s a simplified version of your Maven config:
4.0.0
org.springframework.boot
spring-boot-starter-parent
3.5.3
com.kscodes.springboot
demo
0.0.1-SNAPSHOT
demo
Demo project for Spring Boot
21
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-maven-plugin
๐ก Step 4: Your First Spring Boot Application
File: DemoApplication.java
package com.kscodes.springboot.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);
}
}
๐ Step 5: Add a Simple REST Controller
File: HelloController.java
package com.kscodes.springboot.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, World!
" +
"Welcome to KSCodes!
" +
"This is our first message โ a simple one, but classic:";
}
}
โถ๏ธ Step 6: Run the Application
Run the app using any of the following methods:
Method 1: From IDE
Run DemoApplication.java as a Java application.
Method 2: From Command Line
mvnw spring-boot:run
๐ Step 7: Test Your REST Endpoint
Open your browser or use a tool like Postman:

๐ Summary
Youโve just created your first Spring Boot 3.x application using Maven. You:
- Generated a project with Spring Initializr
- Understood the Maven structure
- Built and ran a basic REST API