Getting Started with Spring Boot: A Beginner’s Guide
Source: Dev.to – Getting Started with Spring Boot: A Beginner’s Guide

Introduction
Spring Boot is a powerful Java framework that simplifies the creation of modern backend applications. In this guide you’ll learn:
- The basics of Spring Boot
- How to create a new project
- The typical project structure
- Managing dependencies with Maven/Gradle
- Building a simple REST API
🧠 Prerequisites
Before we begin, you should have a basic understanding of:
- Core Java concepts
- Object‑Oriented Programming (OOP)
- Classes, methods, and interfaces
- Basic database concepts (tables, primary keys, foreign keys)
- Writing simple SQL queries
These fundamentals will help you follow along more easily.
🎯 What You’ll Learn
In this article you will cover:
- What Spring Boot is
- Why Spring Boot was introduced
- Creating a Spring Boot project
- Understanding the project structure
- Managing dependencies with Maven
- Building and running a Spring Boot app
- Creating a simple REST API
Source Code
You can view the exact code in the GitHub repository:
📦 Introduction to Spring Boot
Spring Boot is a Java framework built on top of the Spring Framework. It simplifies development by reducing manual configurations and setup.
Instead of writing extensive XML or Java configuration and setting up external servers, Spring Boot provides:
- Auto‑configuration
- Embedded servers
- Opinionated defaults
- Easy REST API support
These features make it ideal for building standalone, production‑ready applications.
🧩 Why Spring Boot Was Introduced
Before Spring Boot
- Projects required lots of configuration.
- Developers wrote repetitive boilerplate code.
- Dependency management was manual.
- An external application server was needed.
What Spring Boot Solves
Spring Boot standardizes and automates much of the setup, eliminating the pain points listed above.
⭐ Key Features of Spring Boot
- ✔ Auto‑Configuration – Automatically configures the application based on its dependencies.
- ✔ Embedded Servers – Includes Tomcat, Jetty, or Undertow, so no external server is required.
- ✔ Easy REST APIs – Build web APIs with minimal code.
- ✔ Database Integration – Seamlessly works with JDBC, JPA, and popular databases.
- ✔ Spring Security Support – Built‑in authentication and authorization capabilities.
🚀 Create a Spring Boot Project
The easiest way is to use Spring Initializr – just go to
https://start.spring.io.
Steps
- Open Spring Initializr
- Configure the project
- Project: Maven
- Language: Java
- Spring Boot version: (default)
- Group:
com.codewithtejas - Artifact:
store - Java version: 17
- Add dependency:
Spring Web - Click Generate
- Extract the downloaded .zip file into your workspace.
📁 Understanding the Project Structure
store
├── .mvn
├── src
│ ├── main
│ │ ├── java
│ │ └── resources
│ └── test
│ └── java
├── pom.xml
└── target/ ← generated build output
Key Elements
pom.xml– Maven descriptor that manages dependencies and the build lifecycle.mvnw/mvnw.cmd– Maven wrapper scripts ensuring a consistent Maven version across environments.src/main/java– Application source code.src/main/resources– Configuration files (e.g.,application.properties).src/test/java– Unit and integration tests (typically JUnit).target/– Directory created by Maven containing compiled classes, packaged artifacts, and other build artifacts.
🛠 Managing Dependencies with Maven
Maven dependencies are declared in the project’s pom.xml file. A typical Spring Boot web dependency looks like this:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- version is usually omitted because Spring Boot’s dependency management provides it -->
</dependency>
</dependencies>
| Element | Meaning |
|---|---|
| groupId | The organization or project group (e.g., org.springframework.boot). |
| artifactId | The name of the library/module (e.g., spring-boot-starter-web). |
| version | The specific version of the library. Often left out when using Spring Boot’s BOM, which supplies the appropriate version automatically. |
What spring-boot-starter-web brings in
- Spring MVC – the core web framework
- Embedded Tomcat – default servlet container (can be swapped for Jetty/Undertow)
- Jackson – JSON serialization/deserialization
- Validation – Bean Validation (JSR‑380) support
Updating Dependencies
After you edit pom.xml, Maven (or your IDE) will usually detect the change and reload the project automatically.
If you need to trigger a manual refresh, run:
# Clean the project and re‑download any updated dependencies
mvn clean install
Other useful commands:
mvn dependency:tree– visualise the full dependency graph.mvn versions:display-dependency-updates– list newer versions of your dependencies.
Building and Running a Spring Boot Application
Creating a Simple REST Controller
Step 1: Create a Controller Package
com.codewithtejas.store.controller
Step 2: Create the Controller Class
@RestController
@RequestMapping("/api")
public class HelloController {
@GetMapping("/hello")
public String hello() {
return "Hello from Spring Boot!";
}
}
Explanation of Annotations
@RestController– Marks the class as a REST controller.@RequestMapping("/api")– Base URL path for all endpoints in the class.@GetMapping("/hello")– Handles HTTP GET requests to/api/hello.
Run the Application
Using Maven Wrapper (recommended):
./mvnw spring-boot:run
Or, if Maven is installed globally:
mvn spring-boot:run
The application starts on port 8080 by default. Visit http://localhost:8080/api/hello to see the response.
🚀 What’s Next?
Now that you understand the basics of Spring Boot, the next important step is learning Dependency Injection (DI) and the Inversion of Control (IoC) Container. These concepts are the foundation of the Spring Framework and are used everywhere in Spring Boot applications.
Let’s Connect!
If you have any recommended resources, better approaches to my challenges, or insights, I’d love to hear them! Drop your thoughts in the comments.
Happy coding! 🎉
Have a wonderful day!
