Spring Boot Tutorial for Beginners with Examples: Learn by Doing

Logan Jul 13, 2026

Spring Boot, a widely-used framework by developers for creating modern Java applications, offers a gentle learning curve for beginners. With its emphasis on convention over configuration and automatic configuration, it allows you to dive right into developing your application instead of spending countless hours on setting up the environment. Let's explore Spring Boot with this beginner-friendly tutorial, chock-full of hands-on examples.

Learn Spring Boot by Annotations
Learn Spring Boot by Annotations

Before we begin, ensure you have Java Development Kit (JDK) 8 or later installed and the Spring Tool Suite (STS) integrated development environment (IDE) set up. We'll also be using Gradle for build automation, so install that too if it's not part of your STS setup.

Building a Hello World Web Application with Spring MVC and JSP | Spring Boot Guide
Building a Hello World Web Application with Spring MVC and JSP | Spring Boot Guide

Setting Up Your First Spring Boot Project

We'll start by creating our first Spring Boot project. Launch STS, choose "Spring Boot" from the welcome screen, and follow these steps:

Spring Boot Hello World Example: Beginners Guide
Spring Boot Hello World Example: Beginners Guide

1. Select "Maven Project" or "Gradle Project" based on your preference. For this tutorial, we'll use Gradle. Choose the "Empty" project to start with a clean slate.

Project Structure

Spring Boot Security-Scheduling-Transactions Annotations With Examples
Spring Boot Security-Scheduling-Transactions Annotations With Examples

After creating the project, you'll see a simple structure: src/main/java, src/main/resources, and build.gradle (or pom.xml, if using Maven). The main application and other Java classes live under main/java, while application.properties and other configuration files live under main/resources.

Creating the Main Application Class

Create a new class under main/java, naming it "HelloWorldApplication". This class will hold our main application method. Following is the basic structure:

What Is Spring Boot in Java? Beginner Guide 2026
What Is Spring Boot in Java? Beginner Guide 2026

```java package com.example.helloworld; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class HelloWorldApplication { public static void main(String[] args) { SpringApplication.run(HelloWorldApplication.class, args); } } ```

Running Your Spring Boot Application

After creating the main application class, right-click on the project folder, and choose "Run As" -> "Spring Boot App". STS will launch your application, and you should see the following output:

Spring Boot Microservice Project with Postgres DB Tutorial with Java Example for Beginners
Spring Boot Microservice Project with Postgres DB Tutorial with Java Example for Beginners

. ____ _ __ _____ /\\ / ___'_ __ _ _(_)_ __ __ _ \n ( ( )\___ / '__| | | | '_ \/ _` | \n \\/ ___)| | | | | | | || (_| | \n ' |____| |__|_| |_|_| \_, |\n |____/ \n ====-Spring Boot- reference -==== Carztwa Dev fara fara?

Congratulations! You've just run your first Spring Boot application.

Spring Boot CRUD and JPA: Your Ultimate Book Example Guide
Spring Boot CRUD and JPA: Your Ultimate Book Example Guide
Student Management System Project - FullStack Java + Spring Boot + React.js Example Tutorial
Student Management System Project - FullStack Java + Spring Boot + React.js Example Tutorial
Spring Boot + MySQL + Spring Data JPA: A Beginner's Guide to REST API CRUD Operations
Spring Boot + MySQL + Spring Data JPA: A Beginner's Guide to REST API CRUD Operations
Tulip Painting - With Rain Boots - Step By Step Tutorial
Tulip Painting - With Rain Boots - Step By Step Tutorial
Spring Boot Tutorial
Spring Boot Tutorial
Java Spring Boot Development Services in USA
Java Spring Boot Development Services in USA
Spring Boot + Kotlin + AngularJS + WebJar CRUD Example Part 2 » Tell Me How - A Place for Technology Geekier
Spring Boot + Kotlin + AngularJS + WebJar CRUD Example Part 2 » Tell Me How - A Place for Technology Geekier
Top 10 Free Core Spring, Spring MVC, and Spring Boot Courses for Beginners in 2026 - Best of Lot
Top 10 Free Core Spring, Spring MVC, and Spring Boot Courses for Beginners in 2026 - Best of Lot
Student Management System Project - FullStack Java + Spring Boot + React.js Example Tutorial
Student Management System Project - FullStack Java + Spring Boot + React.js Example Tutorial
Spring Boot: Soft Delete functionality with Hibernate
Spring Boot: Soft Delete functionality with Hibernate
Spring Boot RabbitMQ Tutorial | Send Messages to Queue with Annotations
Spring Boot RabbitMQ Tutorial | Send Messages to Queue with Annotations
7 French Spring Boots
7 French Spring Boots
Top 20 Spring and REST Interview Questions Answers for Java/JEE Programmers
Top 20 Spring and REST Interview Questions Answers for Java/JEE Programmers
How To Draw Boots – A Step by Step Guide
How To Draw Boots – A Step by Step Guide
Easy DIY Spring Sock Gnome with Boots
Easy DIY Spring Sock Gnome with Boots
3 Ways to change Embedded Tomcat Server Port in Spring Boot Application - Example
3 Ways to change Embedded Tomcat Server Port in Spring Boot Application - Example
How to Draw a Rubber Boot
How to Draw a Rubber Boot
Java Spring Tutorial for Beginners and Professionals | Linkgeanie.com
Java Spring Tutorial for Beginners and Professionals | Linkgeanie.com
how to paint leather cowgirl boots
how to paint leather cowgirl boots

Checking Application Listening Port

By default, Spring Boot applications listen on port 8080. You can verify this by checking your application.properties file. Just look for "server.port" and make sure it's set to 8080. To test this, open your web browser and navigate to http://localhost:8080. You should see similar output to what's in your terminal.

Testing Application with curl

Alternatively, you can test your application using the command-line tool curl. In the terminal, run the following command:

curl localhost:8080

The output should be the same as above.

Constructing a Simple REST API

Now that we've got our application up and running, let's create a simple REST API. Right-click on the project folder and create a new Java class named "HelloWorldController".

Creating a GET Method

Add the following code to the HelloWorldController class. This will create a new GET method at "/api/hello".

```java package com.example.helloworld; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloWorldController { @GetMapping("/api/hello") public String helloWorld() { return "Hello, World!"; } } ```

الجبل waveguide running, launch your application again and open your web browser. Navigate to http://localhost:8080/api/hello. You should see "Hello, World!" displayed.

Creating a POST Method

To create a POST method, update the HelloWorldController class as follows:

```java package com.example.helloworld; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloWorldController { @GetMapping("/api/hello") public String helloWorld() { return "Hello, World!"; } @PostMapping("/api/hello") public String helloWorld(@RequestParam String name) { return "Hello, " + name + "!"; } } ```

Now, restart your application and test the POST method using curl:

curl -X POST "localhost:8080/api/hello?name=John"

You should see "Hello, John!" returned.

Building and Packaging Your Application

The beauty of Spring Boot lies in its ease of packaging. You can create a single, executable JAR file for deployment. Just right-click on the project folder, and choose "Export" -> "Java/Archive". Follow the prompts, and you'll have your first packaged Spring Boot application.

That's it! You're now well-versed in the basics of Spring Boot. Happy coding!