00:00

Spring Boot Introduction

Spring Boot is the most popular way to build Java applications today, from small web services to large enterprise systems. It takes care of the setup work that used to slow Java projects down, so you can go from an empty folder to a running web application in a few minutes.

This beginner-friendly introduction explains what Spring Boot is, how it relates to the Spring Framework, which problems it solves and how it works. It then walks you through building, running and configuring your first application.

1. What Is Spring Boot?

Spring Boot is a free, open-source Java framework for building applications on top of the Spring Framework. It gives you sensible default settings, ready-made dependency bundles and a built-in web server, so most applications need very little setup to start working.

Think of the Spring Framework as a big, well-equipped kitchen: it has every tool you could want, but you must choose and arrange everything yourself before you can cook. Spring Boot is the same kitchen, already set up for the most common recipes. You can start cooking straight away, and you can still rearrange anything you like.

With Spring Boot you can build:

  • REST APIs and web applications
  • Microservices
  • Batch jobs and scheduled tasks
  • Applications that process messages from Kafka or RabbitMQ
  • Command-line tools

2. Spring Framework vs Spring Boot

Spring Boot does not replace Spring; it is built on top of it. Everything you learn about Spring still applies. Spring Boot simply removes much of the manual work:

Spring FrameworkSpring Boot
What it isThe core framework: dependency injection, web, data access and moreA layer on top of Spring that configures it for you
ConfigurationYou set up most beans yourself, in Java or XMLSensible defaults, applied automatically
DependenciesYou choose each library and a compatible versionStarters bring tested sets of libraries
Web serverYou install Tomcat separately and deploy a WAR fileA server is built in; you run a single JAR file
Production featuresYou add health checks and metrics yourselfReady-made with Spring Boot Actuator
Getting startedSlower, with more decisions up frontMinutes, with a generated project

For a deeper comparison, including the same application built both ways, see Spring Boot vs Spring Framework.

3. Why Was Spring Boot Created?

Before Spring Boot, starting a Spring project meant a lot of repetitive setup:

  • Long configuration files. Even a small web application needed many lines of XML or Java configuration to wire up the database, transactions and the web layer.
  • Version conflicts. You had to find versions of Spring, Hibernate, Jackson and other libraries that worked together, and one mismatch could cause confusing errors.
  • Separate server setup. Applications were packaged as WAR files and deployed to an application server that had to be installed and configured separately.
  • Repeated boilerplate. Every new project copied the same setup from the previous one.

Spring Boot, first released in 2014, solved these problems with convention over configuration: if you follow common conventions, the framework handles the details, and you only write configuration when you want something different.

4. Key Features of Spring Boot

4.1 Auto-configuration

Spring Boot looks at the libraries in your project and configures them automatically. Add a database driver, and it sets up a connection pool. Add the web starter, and it configures a web server and JSON support. If you define your own version of something, Spring Boot uses yours instead.

4.2 Starters

A starter is a single dependency that brings in everything needed for one kind of work, in versions that are tested together. One line gives you a complete web stack:

pom.xml
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

Notice that there is no version number. Spring Boot manages compatible versions for you.

4.3 Embedded web server

Spring Boot includes a web server (Tomcat by default; Jetty is an alternative) inside your application. You run the application like any Java program, and the server starts with it. There is nothing to install separately.

4.4 Externalized configuration

Settings such as the port, database URL or feature switches live outside your code, in application.properties, environment variables or command-line arguments. The same build can then run in development, testing and production with different settings.

4.5 Production-ready features

Spring Boot Actuator adds health checks, metrics and information endpoints, so you can monitor your application in production without writing that code yourself.

4.6 Developer tools

Spring Boot DevTools restarts the application automatically when you change code during development, which saves you from stopping and starting it by hand.

5. How Spring Boot Works

When you start a Spring Boot application, these steps happen in a few seconds:

  1. The main method calls SpringApplication.run(...).
  2. Spring Boot reads your configuration from application.properties and other sources.
  3. It scans your packages for classes marked with annotations such as @RestController and @Service, and creates objects (called beans) for them.
  4. It runs auto-configuration, creating beans for the libraries it finds, such as a web server or a database connection.
  5. It connects the beans together through dependency injection.
  6. It starts the embedded web server, and your application is ready to accept requests.

6. What You Need Before You Start

ToolNotes
Java Development Kit (JDK) 17 or newerCurrent Spring Boot versions require at least Java 17; Java 21 or newer is a good choice
A build toolMaven or Gradle; every generated project includes a wrapper, so you do not need to install either
An IDEIntelliJ IDEA, Eclipse with Spring Tools, or VS Code with the Java and Spring extensions
Basic Java knowledgeClasses, interfaces, annotations and collections

Check your Java version in a terminal:

Terminal
java -version

7. Creating Your First Spring Boot Application

The easiest way to create a project is Spring Initializr, a free online project generator at start.spring.io. Most IDEs offer the same generator built in.

FieldChoose
ProjectMaven
LanguageJava
Spring BootThe latest stable version (no SNAPSHOT or RC label)
Groupcom.javabytechie
Artifactgreeting
PackagingJar
Java17 or newer
DependenciesSpring Web

Click Generate, unzip the downloaded file, and open the folder in your IDE. The IDE downloads the dependencies automatically; this takes a minute the first time.

8. Understanding the Project Structure

Project layout
greeting/
├── mvnw, mvnw.cmd                  Maven wrapper scripts (no Maven install needed)
├── pom.xml                         Dependencies and build settings
└── src/
    ├── main/
    │   ├── java/com/javabytechie/greeting/
    │   │   └── GreetingApplication.java     The main class
    │   └── resources/
    │       ├── application.properties       Configuration
    │       ├── static/                      Images, CSS, JavaScript
    │       └── templates/                   HTML templates (if used)
    └── test/
        └── java/com/javabytechie/greeting/
            └── GreetingApplicationTests.java

The generated pom.xml inherits from spring-boot-starter-parent, which supplies tested library versions and build defaults:

pom.xml
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.5.0</version> <!-- the version you chose on start.spring.io -->
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

9. The Main Application Class

Every Spring Boot application has one class with a main method and the @SpringBootApplication annotation:

GreetingApplication.java
package com.javabytechie.greeting;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class GreetingApplication {

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

@SpringBootApplication switches on three things at once: configuration support, auto-configuration, and scanning of this package and its sub-packages for your classes. That is why the main class should sit in the top-level package, above all your other code. For a closer look, see Spring Boot Annotations.

10. Writing Your First REST Endpoint

Create a new class next to the main class. This controller answers HTTP requests with JSON:

GreetingController.java
package com.javabytechie.greeting;

import java.time.LocalDateTime;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GreetingController {

    @GetMapping("/hello")
    public Greeting hello(@RequestParam(defaultValue = "World") String name) {
        return new Greeting("Hello, " + name + "!", LocalDateTime.now());
    }

    public record Greeting(String message, LocalDateTime time) {
    }
}
PartMeaning
@RestControllerThis class handles web requests and returns data, not HTML pages
@GetMapping("/hello")Run this method for GET requests to /hello
@RequestParamRead name from the URL, for example ?name=Asha
Returning a recordSpring Boot converts it to JSON automatically

11. Running the Application

Start the application from your IDE by running the main method, or from a terminal in the project folder:

Terminal
# macOS / Linux
./mvnw spring-boot:run

# Windows
mvnw.cmd spring-boot:run

After a few seconds, the log shows that the server is ready:

Console
Tomcat started on port 8080 (http) with context path '/'
Started GreetingApplication in 1.8 seconds (process running for 2.1)

Open http://localhost:8080/hello?name=Asha in your browser, or call it from a terminal:

Terminal
curl "http://localhost:8080/hello?name=Asha"
Response
{
  "message": "Hello, Asha!",
  "time": "2026-10-04T10:30:15.482"
}

Congratulations: that is a working web service, with no XML, no server installation and no manual wiring.

11.1 Building a runnable JAR

To run the application on a server, package it as one self-contained JAR file:

Terminal
./mvnw clean package
java -jar target/greeting-0.0.1-SNAPSHOT.jar

The JAR contains your code, all libraries and the web server, so any machine with Java can run it.

12. Configuring the Application

Change the defaults in src/main/resources/application.properties:

application.properties
# Run on port 9090 instead of 8080
server.port=9090

# A name for the application, shown in logs and monitoring tools
spring.application.name=greeting-service

# Your own settings
greeting.default-name=Friend

Read your own settings in code with @Value:

GreetingController.java
@RestController
public class GreetingController {

    private final String defaultName;

    public GreetingController(@Value("${greeting.default-name}") String defaultName) {
        this.defaultName = defaultName;
    }

    @GetMapping("/hello")
    public Greeting hello(@RequestParam(required = false) String name) {
        String who = (name == null || name.isBlank()) ? defaultName : name;
        return new Greeting("Hello, " + who + "!", LocalDateTime.now());
    }
}

Any property can also be overridden when starting the application, without changing the file:

Terminal
java -jar target/greeting-0.0.1-SNAPSHOT.jar --server.port=7070

13. Common Spring Boot Starters

StarterAdds
spring-boot-starter-webREST APIs and web applications, with Tomcat and JSON support
spring-boot-starter-data-jpaDatabase access with JPA and Hibernate
spring-boot-starter-validationValidation of input data with annotations
spring-boot-starter-securityLogin, authentication and authorization
spring-boot-starter-actuatorHealth checks, metrics and monitoring endpoints
spring-boot-starter-thymeleafServer-side HTML pages
spring-boot-starter-cacheCaching method results
spring-boot-starter-testJUnit 5, Mockito, AssertJ and Spring test support

You can add starters at any time: put the dependency in pom.xml, reload the project, and Spring Boot configures the new feature on the next start.

14. Advantages and Limitations

14.1 Advantages

  • Fast to start: a working project in minutes, with almost no setup.
  • Less code: auto-configuration removes most boilerplate.
  • Fewer version problems: starters bring libraries that are tested together.
  • Easy to run anywhere: one JAR file with a built-in server, ideal for containers and the cloud.
  • Production-ready: health checks, metrics and externalized configuration out of the box.
  • Huge ecosystem: integrations for almost every database, message broker and cloud service.
  • Strong community: plenty of documentation, examples and answers online.

14.2 Limitations

  • “Magic” can confuse beginners: when something is configured automatically, it is not always obvious where it came from.
  • Larger applications: starters may bring libraries you never use, which makes the JAR bigger.
  • Startup time and memory: a typical application uses more memory and starts more slowly than a plain Java program, although native images can help.
  • Learning curve: understanding the Spring concepts underneath still takes time.

15. What to Learn Next

Once your first application runs, these tutorials build on it step by step:

TopicWhat you will learn
Spring Boot AnnotationsThe annotations you will use every day
Spring Boot ValidationChecking request data with annotations
Exception HandlingReturning clear error responses
Spring Data JPASaving and reading data from a database
CachingMaking slow operations fast
Async ProcessingRunning work in the background
SchedulerRunning tasks automatically on a schedule
ActuatorMonitoring your application in production

16. Summary

Spring Boot builds on the Spring Framework and removes most of the setup work: auto-configuration provides sensible defaults, starters bring compatible libraries, and an embedded server lets you run everything as a single JAR. In this tutorial, you created a project with Spring Initializr, explored its structure, wrote a REST endpoint, ran it, and changed its configuration. From here, add features one starter at a time, and dive into the tutorials above as your application grows.