Starting with a “Hello World” application is the simplest and most effective way to understand how Spring Boot works.
This guide walks you through creating, running, and understanding your first Spring Boot application, while also explaining what happens behind the scenes in real-world systems.
This post is designed for:
- Beginners learning Spring Boot
- Developers moving from Spring Framework
- Engineers preparing for production-grade applications
What Is a Spring Boot Hello World Application?
A Spring Boot Hello World application is the smallest possible Spring Boot project that:
- Starts an embedded web server
- Exposes a REST endpoint
- Returns a simple response like
"Hello World"
Even though it looks simple, this application demonstrates:
- Auto-configuration
- Embedded server startup
- Component scanning
- REST API handling
These same mechanisms power large production systems.
Prerequisites
Before starting, make sure you have:
- Java 17 or later installed
- Maven or Gradle
- Basic Java knowledge
- An IDE like IntelliJ IDEA, Eclipse, or VS Code
No prior Spring experience is required.
Creating a Spring Boot Project
The easiest way to create a Spring Boot project is using Spring Initializr.
Choose the following options:
- Project: Maven
- Language: Java
- Spring Boot version: Stable default
- Packaging: Jar
- Java version: 17+
- Dependencies: Spring Web
Once generated, import the project into your IDE.
Project Structure Explained
After creating the project, you will see a structure similar to this:
src
└── main
├── java
│ └── com.example.demo
│ └── DemoApplication.java
└── resources
└── application.properties
This structure is standard across Spring Boot projects and scales well into production systems.
For a deeper understanding of how this structure evolves in real projects, see:
spring boot project structure explained beginner to production guide
Main Application Class
The entry point of a Spring Boot application looks like this:
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
What @SpringBootApplication Does
This single annotation combines:
@Configuration@EnableAutoConfiguration@ComponentScan
Together, they tell Spring Boot to:
- Load configuration
- Auto-configure components
- Scan your project for beans
Creating a Hello World REST Controller
Now let’s expose a simple API endpoint.
@RestController
public class HelloController {
@GetMapping("/hello")
public String hello() {
return "Hello World";
}
}
This creates an HTTP GET endpoint available at /hello.
Running the Application
Run the application using:
- Your IDE’s Run button
or - The command line:
mvn spring-boot:run
Once started, open your browser and visit:
http://localhost:8080/hello
You should see:
Hello World
What Happens When the Application Starts?
When you run the app, Spring Boot:
- Starts the JVM
- Initializes the Spring context
- Creates beans
- Starts the embedded web server (Tomcat by default)
- Maps controllers to URLs
To fully understand this startup flow, read: how spring boot application starts startup flow explained
Common Beginner Issues and Fixes
Port 8080 Already in Use
If you see an error saying port 8080 is already in use, it means another process is using that port.
You can fix it by:
- Stopping the conflicting process
- Or changing the server port
Full guide:
how to fix port 8080 already in use error in spring boot
Application Starts but URL Not Working
Common reasons:
- Wrong endpoint path
- Controller package outside component scan
- Missing
@RestController
Understanding how beans are created helps here:
how spring boot creates beans bean lifecycle simplified for production
Why Hello World Matters Beyond Beginners
Although this example is simple, it teaches core concepts used everywhere in Spring Boot:
- Dependency Injection
- Auto-configuration
- REST APIs
- Embedded servers
Every advanced feature—profiles, security, databases, cloud deployment—builds on this foundation.
To see how configuration changes across environments, read:
spring boot configuration and profiles explained beginner to production guide
Summary
In this guide, you learned:
- What a Spring Boot Hello World app is
- How to create and run it
- How REST endpoints work
- What happens during startup
- Common beginner issues and fixes
This is your foundation for all future Spring Boot topics.
Frequently Asked Questions
Is Spring Boot Hello World used in real projects?
Yes. Real projects start with this structure and evolve with more components.
Can I use Gradle instead of Maven?
Yes. Spring Boot fully supports both.
Why does Spring Boot start a server automatically?
Spring Boot includes an embedded server so applications are self-contained and production-ready.
What should I learn next?
Dependency Injection, bean lifecycle, profiles, and REST API design.
