Spring Boot 4 Tutorial for Beginners: Build Your First Application in 2026
This Spring Boot 4 tutorial for beginners explains how to create and run your first Spring Boot application in 2026. We will use Java, Maven and Spring MVC to build simple REST endpoints and understand the essential concepts required for modern Spring Boot development.
Spring Boot continues to be one of the most popular technologies for developing Java-based web applications, REST APIs, microservices, and enterprise applications. With Spring Boot 4, developers get a modern platform built around the latest generation of the Spring ecosystem.
If you are learning Spring Boot in 2026, starting directly with Spring Boot 4 makes sense. In this tutorial, we will understand the basic concepts of Spring Boot and create our first Spring Boot 4 web application step by step.
By the end of this tutorial, you will be able to:
- Understand what Spring Boot is
- Understand how Spring Boot differs from the traditional Spring Framework
- Create a Spring Boot 4 project
- Understand the generated project structure
- Create a REST controller
- Run the application
- Access the application through a web browser
- Add multiple endpoints
- Build an executable JAR file
What is Spring Boot?
Spring Boot is a framework built on top of the Spring Framework that simplifies the development of Java applications.
Traditional Spring applications often require developers to perform considerable configuration before an application can run. Spring Boot reduces this configuration by providing sensible defaults and automatically configuring many components based on the dependencies included in the project.
For example, when the dependencies required for a Spring MVC web application are included, Spring Boot can configure the web environment and embedded server automatically.
Therefore, instead of spending a large amount of time configuring the application, developers can concentrate on writing application logic.
Why Use Spring Boot?
Spring Boot provides several advantages for Java developers.
1. Auto-Configuration
Spring Boot automatically configures many components according to the libraries available in the project.
For example, when Spring MVC and an embedded server are available, Spring Boot recognizes that the project is a web application and configures the required infrastructure.
2. Embedded Web Server
A Spring Boot application can run with an embedded web server.
This means that beginners generally do not have to download and configure a separate Tomcat server just to run their first application.
3. Starter Dependencies
Spring Boot provides starter dependencies that group together commonly required libraries.
For example, a Spring MVC application can use:
spring-boot-starter-webmvc
Instead of manually finding and configuring every required library, the starter brings together the dependencies required for the application.
4. Standalone Applications
Spring Boot applications can be packaged as executable JAR files and started using:
java -jar application.jar
5. Production-Oriented Features
Spring Boot also provides features for developing production applications, including application configuration, monitoring, logging, health information, metrics and externalized configuration.
Spring Framework vs Spring Boot
Spring Boot does not replace the Spring Framework.
Instead, it makes Spring applications easier to configure, develop and run.
| Spring Framework | Spring Boot |
|---|---|
| Core Java application framework | Built on top of Spring Framework |
| More configuration may be required | Provides auto-configuration |
| Dependencies can require manual management | Provides starter dependencies |
| Server configuration may be required | Supports embedded servers |
| Greater initial setup | Faster project setup |
| Provides features such as dependency injection and MVC | Simplifies the use of those Spring features |
A simple way to understand the relationship is:
Spring Framework
↓
Core Spring Features
↓
Spring Boot
↓
Faster Configuration and Development
What is New About Spring Boot 4?
Spring Boot 4 represents a new generation of the Spring Boot platform.
It is based on the modern Spring Framework 7 generation and continues Spring’s move toward modern Java, Jakarta APIs, improved modularity, observability and cloud-native application development.
For beginners, however, the most important point is simple:
The basic Spring Boot programming model remains easy to learn.
You still create an application, define controllers, map URLs and let Spring Boot handle much of the underlying configuration.
Software Required
Before creating the application, install the following tools.
Java Development Kit
Spring Boot 4 requires a modern Java environment. Java 17 or later should be used.
Check the installed Java version using:
java -version
You should see output indicating that Java is installed.
For example:
openjdk version "17..."
You can also use a newer supported Java release.
IDE
You can use any Java IDE, including:
- IntelliJ IDEA
- Eclipse
- Spring Tools
- Visual Studio Code with Java extensions
For beginners already familiar with Eclipse, Eclipse or Spring Tools is perfectly suitable.
Maven
We will use Maven for dependency management and building the application.
Check Maven using:
mvn -version
When a project is generated with Maven Wrapper files, you can also build and run it without separately managing a global Maven installation.
Creating Our First Spring Boot 4 Project
The easiest way to create a Spring Boot project is Spring Initializr.
Open:
start.spring.io
Spring Initializr generates the basic project structure and configuration automatically.
Step 1: Configure the Project
Select the following options.
Project: Maven
Language: Java
Spring Boot: 4.x
Packaging: Jar
Java: 17 or later
Enter project metadata such as:
Group: com.programmingempire
Artifact: firstapp
Name: firstapp
Package name: com.programmingempire.firstapp
Step 2: Add Spring Web Dependency
Click Add Dependencies.
Search for:
Spring Web
Add the appropriate Spring MVC web starter offered by Spring Initializr.
Spring Boot 4’s current dependency model uses the Spring MVC starter for conventional servlet-based web applications.
This gives the application the components needed to:
- Handle HTTP requests
- Create REST APIs
- Use Spring MVC
- Run an embedded web server
Step 3: Generate the Project
Click:
GENERATE
A ZIP file will be downloaded.
Extract the ZIP file to a suitable location.
For example:
D:\SpringBootProjects\firstapp
Step 4: Import the Project into the IDE
In Eclipse, select:
File
→ Import
→ Maven
→ Existing Maven Projects
Browse to the extracted project directory.
Select the project and click:
Finish
Maven may take a short time to download the required dependencies.
Understanding the Project Structure
The generated project will have a structure similar to:
firstapp
│
├── src/main/java
│ └── com.programmingempire.firstapp
│ └── FirstappApplication.java
│
├── src/main/resources
│ ├── static
│ ├── templates
│ └── application.properties
│
├── src/test/java
│
├── pom.xml
│
├── mvnw
└── mvnw.cmd
Let us understand the important components.
pom.xml
The pom.xml file is the Maven configuration file.
It contains information about:
- Project details
- Dependencies
- Java version
- Spring Boot version
- Build plugins
A web application includes a Spring MVC web dependency.
For example:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
Spring Boot manages compatible versions of its supported dependencies, which means developers normally do not need to specify individual versions for every Spring library.
The Main Application Class
Open:
FirstappApplication.java
The generated class will look similar to:
package com.programmingempire.firstapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class FirstappApplication {
public static void main(String[] args) {
SpringApplication.run(FirstappApplication.class, args);
}
}
This is the entry point of our Spring Boot application.
Understanding @SpringBootApplication
The annotation:
@SpringBootApplication
is one of the most important annotations in Spring Boot.
It combines three important capabilities:
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan
@SpringBootConfiguration
Identifies the class as a configuration class for the Spring Boot application.
@EnableAutoConfiguration
Allows Spring Boot to automatically configure the application according to the dependencies available in the project.
@ComponentScan
Allows Spring to search for components such as controllers and services in the application’s package hierarchy.
Understanding the main() Method
Consider:
public static void main(String[] args) {
SpringApplication.run(FirstappApplication.class, args);
}
This is a standard Java main() method.
The statement:
SpringApplication.run()
starts the Spring application.
For a web application, Spring Boot also starts the configured embedded web server.
Creating Our First Controller
Now let us create a web endpoint.
Create a new Java class named:
HelloController.java
Place it in:
com.programmingempire.firstapp
Add the following code:
package com.programmingempire.firstapp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/")
public String home() {
return "Hello from Spring Boot 4!";
}
}
Our first Spring Boot web application is ready.
Understanding @RestController
The annotation:
@RestController
tells Spring that this class handles web requests and that return values from its handler methods should be written directly to the HTTP response.
For example:
return "Hello from Spring Boot 4!";
will be returned directly to the browser.
Understanding @GetMapping
Consider:
@GetMapping("/")
It maps an HTTP GET request to the specified method.
The / represents the root URL of the application.
Therefore, when a user opens:
http://localhost:8080/
Spring executes:
home()
and returns:
Hello from Spring Boot 4!
Running the Spring Boot Application
Run:
FirstappApplication.java
In Eclipse, you can right-click the file and select:
Run As
→ Java Application
or use the available Spring Boot run option.
You can also run the application from the terminal using Maven Wrapper.
On Windows:
mvnw.cmd spring-boot:run
On Linux/macOS:
./mvnw spring-boot:run
If Maven is installed globally, you can use:
mvn spring-boot:run
Spring Boot will start the application and its embedded web server.
Testing the Application
Open a browser and enter:
http://localhost:8080
The browser should display:
Hello from Spring Boot 4!
Congratulations! You have created and executed your first Spring Boot 4 application.
Adding Another Endpoint
Let us add another method to HelloController.
@GetMapping("/welcome")
public String welcome() {
return "Welcome to Programming Empire!";
}
The complete controller becomes:
package com.programmingempire.firstapp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/")
public String home() {
return "Hello from Spring Boot 4!";
}
@GetMapping("/welcome")
public String welcome() {
return "Welcome to Programming Empire!";
}
}
Restart the application if necessary and visit:
http://localhost:8080/welcome
Output:
Welcome to Programming Empire!
Returning Dynamic Data
We can also accept information from the URL.
Import:
import org.springframework.web.bind.annotation.RequestParam;
Then add:
@GetMapping("/hello")
public String hello(@RequestParam(defaultValue = "Guest") String name) {
return "Hello, " + name + "!";
}
Now visit:
http://localhost:8080/hello?name=Juhi
The output will be:
Hello, Juhi!
If you visit:
http://localhost:8080/hello
the output will be:
Hello, Guest!
This demonstrates how a Spring Boot application can receive data from an HTTP request.
Returning JSON from Spring Boot
REST APIs usually return data in JSON format rather than plain text.
Create a simple Java record:
public record Student(
int id,
String name,
String course
) {
}
Now add another endpoint:
@GetMapping("/student")
public Student getStudent() {
return new Student(101, "Cherry", "MCA");
}
Open:
http://localhost:8080/student
The application will return JSON similar to:
{
"id": 101,
"name": "Cherry",
"course": "MCA"
}
Spring Boot automatically converts the Java object into an HTTP JSON response using its configured JSON infrastructure.
This capability is one of the reasons Spring Boot is widely used for REST API development.
Changing the Server Port
Spring Boot normally runs the web application on port:
8080
Suppose you want to use port 9090.
Open:
src/main/resources/application.properties
Add:
server.port=9090
Restart the application.
Now access:
http://localhost:9090
Creating an Executable JAR
One of Spring Boot’s useful features is the ability to package an application as an executable JAR.
From the project directory, run:
mvn clean package
Or use Maven Wrapper:
./mvnw clean package
On Windows:
mvnw.cmd clean package
After a successful build, Maven creates a JAR inside:
target/
For example:
firstapp-0.0.1-SNAPSHOT.jar
Run it using:
java -jar target/firstapp-0.0.1-SNAPSHOT.jar
The application can now start without launching it from the IDE.
How Does a Spring Boot Request Work?
Consider the following URL:
http://localhost:8080/welcome
The basic flow is:
Browser
↓
HTTP Request
↓
Embedded Web Server
↓
Spring MVC
↓
HelloController
↓
welcome()
↓
HTTP Response
↓
Browser
The developer mainly concentrates on writing the controller and application logic while Spring Boot configures much of the supporting infrastructure.
Important Spring Boot Annotations for Beginners
Here are some annotations you will frequently encounter.
| Annotation | Purpose |
|---|---|
@SpringBootApplication | Main Spring Boot configuration annotation |
@RestController | Creates a REST-style controller |
@Controller | Creates an MVC controller |
@GetMapping | Handles HTTP GET requests |
@PostMapping | Handles HTTP POST requests |
@PutMapping | Handles HTTP PUT requests |
@DeleteMapping | Handles HTTP DELETE requests |
@RequestMapping | Maps requests to controllers or methods |
@RequestParam | Reads query parameters |
@PathVariable | Reads values from URL paths |
@RequestBody | Reads request-body data |
@Service | Identifies a service-layer component |
@Repository | Identifies a data-access component |
@Component | Defines a Spring-managed component |
What is Auto-Configuration?
Auto-configuration is a fundamental Spring Boot concept.
Suppose the project contains the dependencies required for a Spring MVC application.
Spring Boot examines the application’s classpath and configuration and determines which components should be configured.
Conceptually:
Dependencies
↓
Spring Boot examines classpath
↓
Auto-Configuration
↓
Required components configured
↓
Application starts
This significantly reduces repetitive configuration.
What Are Spring Boot Starters?
A starter is a convenient dependency descriptor for a particular type of application.
Examples include starters for:
Spring MVC
Spring Data JPA
Security
Validation
Thymeleaf
WebFlux
Testing
For example, when we later build database applications, we can use the Spring Data JPA starter rather than manually configuring every JPA-related dependency.
Spring Boot 4 Project Architecture
As applications become larger, avoid placing everything inside a single controller.
A common structure is:
com.programmingempire.firstapp
│
├── controller
│
├── service
│
├── repository
│
├── entity
│
├── dto
│
└── FirstappApplication.java
The application flow can then become:
Client
↓
Controller
↓
Service
↓
Repository
↓
Database
This layered approach makes applications easier to understand, test and maintain.
Common Beginner Errors
Port 8080 Already in Use
You may see an error indicating that the web server could not start because port 8080 is already being used.
Either stop the other application or change the Spring Boot port:
server.port=9090
Controller Not Detected
Suppose the main application class is located in:
com.programmingempire.firstapp
Keep controllers in the same package or a subpackage, such as:
com.programmingempire.firstapp.controller
This allows the default component scanning mechanism to find them.
Wrong Java Version
Check Java using:
java -version
Spring Boot 4 requires Java 17 or later, so very old Java installations cannot be used.
Dependencies Not Downloaded
For Maven projects, try:
mvn clean install
In Eclipse you can also update the Maven project.
Spring Boot 4 vs Traditional Java Web Development
In older Java web-development approaches, developers often had to manually configure application servers, deployment descriptors and multiple framework components.
Spring Boot simplifies much of this.
A basic application may require only:
@SpringBootApplication
along with a controller such as:
@RestController
public class HelloController {
@GetMapping("/")
public String home() {
return "Hello Spring Boot!";
}
}
This simplicity is one of Spring Boot’s biggest strengths.
Where is Spring Boot Used?
Spring Boot can be used to develop:
- REST APIs
- Enterprise applications
- Web applications
- Microservices
- Cloud applications
- Backend systems
- Database-driven applications
- Event-driven applications
- Containerized applications
- AI-enabled Java applications
Spring Boot is therefore useful not only for learning Java web development but also for building modern production systems.
What Should You Learn Next?
After creating your first Spring Boot 4 application, the next topics to learn are:
- Spring Boot controllers and request mappings
- GET, POST, PUT and DELETE operations
- Spring Boot REST APIs
- Dependency injection
- Service and repository layers
- Spring Data JPA
- Hibernate ORM
- MySQL database integration
- Validation and exception handling
- Spring Security
- Microservices
- Docker and cloud deployment
A particularly useful next project is a complete CRUD application using Spring Boot 4, Spring Data JPA, Hibernate and MySQL.
Frequently Asked Questions
Is Spring Boot 4 suitable for beginners?
Yes. Although Spring Boot is used for complex enterprise applications, beginners can start with simple controllers and REST endpoints and gradually learn database access, security and microservices.
Do I need to learn the Spring Framework before Spring Boot?
A complete mastery of Spring Framework is not required before starting Spring Boot. However, learning concepts such as dependency injection, inversion of control, beans and Spring MVC will make Spring Boot easier to understand.
Does Spring Boot need Tomcat?
A typical Spring MVC Spring Boot application can use embedded Tomcat, so beginners usually do not need to install Tomcat separately.
Which Java version should I use for Spring Boot 4?
Use Java 17 or a newer version supported by the Spring Boot release you select.
Can Spring Boot create REST APIs?
Yes. REST API development is one of the major uses of Spring Boot. Annotations such as @RestController, @GetMapping, @PostMapping, @PutMapping and @DeleteMapping make REST endpoints straightforward to create.
Is Spring Boot used for microservices?
Yes. Spring Boot is extensively used as a foundation for Java microservices and can be combined with the broader Spring ecosystem for distributed and cloud-native applications.
Conclusion
Spring Boot 4 provides a modern platform for developing Java web applications, REST APIs, microservices and enterprise systems.
In this tutorial, we created our first Spring Boot 4 application, understood the generated project structure, created REST endpoints, accepted request parameters, returned JSON data, changed the server port and packaged the application as an executable JAR.
The most important concepts to remember are:
@SpringBootApplication
↓
Auto-Configuration
↓
Embedded Web Server
↓
@RestController
↓
@GetMapping
↓
REST/Web Application
Once these basic concepts are clear, you can move toward database-driven applications using Spring Boot 4, Spring Data JPA and Hibernate, followed by security, microservices and cloud deployment.
Spring Boot 4 is therefore an excellent starting point for Java developers who want to build modern backend applications in 2026.
Further Reading
Spring Boot 4 vs Spring Boot 3: What Changed?
What Is Claude AI? A Beginner’s Guide (2026)
Claude Code vs ChatGPT Codex: A Practical Comparison for Developers (2026)
What is MCP? A Beginner’s Guide with Python Examples
MCP vs REST API – Key Differences
Build Your First MCP Server in Python
Create an MCP Server for MySQL Database
Integrate OpenAI Agents with MCP
Security Risks in MCP Servers and How to Mitigate Them
What is n8n? A Beginner-Friendly Guide to Workflow Automation
How to Automatically Publish Blog Posts Using n8n (Step-by-Step Guide)
Top 10 Real-World Use Cases of n8n for Developers
Introduction to Django Framework and its Features
Examples of Array Functions in PHP
Registration Form Using PDO in PHP
Inserting Information from Multiple CheckBox Selection in a Database Table in PHP
- Angular
- ASP.NET
- C
- C#
- C++
- CSS
- Dot Net Framework
- HTML
- IoT
- Java
- JavaScript
- Kotlin
- PHP
- Power Bi
- Python
- Scratch 3.0
- TypeScript
- VB.NET
