If you're new to backend development in Java, Spring Boot is the perfect framework to begin your journey. It allows you to build robust, production-grade applications with minimal boilerplate code.

In this blog, I’ll guide you through creating your first Spring Boot project, understanding its folder structure, and building a basic REST APIβ€”all with practical examples and screenshots.


πŸ“Œ What is Spring Boot?

Spring Boot is an open-source Java framework designed to simplify Spring application development. It comes with built-in configurations, embedded servers, and dependency management to reduce boilerplate and speed up your development process.

πŸ”‘ Key Benefits of Spring Boot

  • Zero XML configuration
  • Embedded Tomcat/Jetty/Undertow
  • Auto-configuration for faster setup
  • Powerful Spring ecosystem (Security, Data, Cloud, etc.)

βœ… Step 1: Create Your Project Using Spring Initializr

Spring Initializr is a web-based generator for Spring Boot apps. It’s fast, intuitive, and generates all the project boilerplate for you.

πŸ–₯️ Visit Spring Initializr

πŸ”— https://start.spring.io/

πŸ”§ Configure Your Project

Choose the following options:

  • Project: Maven
  • Language: Java
  • Spring Boot Version: Latest stable (e.g., 3.2.x)
  • Group: com.example
  • Artifact: springboot-demo
  • Name: springboot-demo
  • Description: A demo Spring Boot application
  • Packaging: Jar
  • Java: 17 or higher

πŸ“† Add Dependencies

Click "Add Dependencies" and select:

  • βœ… Spring Web
  • βœ… Spring Boot DevTools (optional, for auto-restart)
  • βœ… Spring Data JPA (optional, for DB operations)
  • βœ… H2 Database (optional, for in-memory DB)

Then click "Generate" to download the .zip file.


πŸ“‚ Step 2: Open the Project in IntelliJ IDEA or Eclipse

πŸ§β€β™€οΈ Extract and Import

  1. Unzip the downloaded project.
  2. Open IntelliJ IDEA β†’ File β†’ Open β†’ Select the extracted folder.

Your folder structure should look like:

springboot-demo/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main/
β”‚   β”‚   β”œβ”€β”€ java/com/example/springbootdemo/
β”‚   β”‚   β”‚   └── SpringbootDemoApplication.java
β”‚   β”‚   └── resources/
β”‚   β”‚       β”œβ”€β”€ application.properties
β”‚   β”‚       └── static/
└── pom.xml

πŸƒ Step 3: Run Your Spring Boot Application

Inside SpringbootDemoApplication.java, you’ll find:

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

▢️ Run From IDE

Click the green run button next to the main() method or right-click β†’ Run.

πŸ—…οΈ Run From Terminal

./mvnw spring-boot:run

You should see:

Tomcat started on port(s): 8080 (http)
Started SpringbootDemoApplication in 2.5 seconds

Open a browser and visit http://localhost:8080


πŸ› οΈ Step 4: Build a Simple REST API

Let’s create a HelloController.java to test if our backend is working.

πŸ“ Create Controller Class

src/main/java/com/example/springbootdemo/controller/HelloController.java

package com.example.springbootdemo.controller;

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!";
    }
}

🌐 Test the API

Now go to your browser and hit: πŸ”— http://localhost:8080/hello

βœ… You should see: Hello, Spring Boot!


🧠 Bonus: Customize application.properties

Edit src/main/resources/application.properties:

server.port=9090
spring.application.name=springboot-demo

Re-run your app and visit: πŸ”— http://localhost:9090/hello


πŸ€” FAQs

Q: Can I add more dependencies later? πŸ‘‰ Yes! Add them to pom.xml and reload your project.

Q: Do I need Tomcat installed? πŸ‘‰ No, Spring Boot embeds Tomcat by default.

Q: Can I use MySQL/PostgreSQL instead of H2? πŸ‘‰ Absolutely. Just add the dependency and update application.properties.


πŸ’ͺ Checklist for Hands-On Practice

Task Status
Create project with Spring Initializr βœ…
Open in IDE βœ…
Run basic app βœ…
Add REST Controller βœ…
Customize configuration βœ…
Hit API in browser βœ…

πŸš€ Conclusion

Spring Boot makes backend development in Java fast, modular, and fun. With just a few steps, you can spin up a working application and start building real features.

Whether you're building REST APIs, connecting databases, or creating full-stack appsβ€”Spring Boot is the go-to choice for Java developers.

So what are you waiting for? Fire up Spring Initializr and start building!


Posted on May 18, 2025