Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 66 ยท Getting Started

What Is Spring Boot?

What Spring Boot is, how it differs from the Spring Framework, which defaults it chooses for you, and what changed between Boot 3 and Boot 4.

Spring Boot is the fastest way to build a production-ready Java application on top of the Spring Framework. You write a small main method, add a few dependencies, and you get a working web server, a database connection, logging, health checks and sensible configuration, without writing XML or wiring infrastructure by hand.

If you have never used Spring, that sentence hides a lot of machinery. This lesson explains what the Spring Framework does, what Boot adds on top, what a Boot application actually is, and which versions you will meet in real projects. The rest of the track builds on this picture: you will learn the container, auto-configuration, REST, data access, security, testing and deployment one chapter at a time.

The real Spring Boot cannot run in our in-browser sandbox, so Spring code in this track is shown read-only. Every lesson also has runnable plain-Java stand-ins that rebuild the idea on a small scale, and each one says clearly what is real and what is the stand-in.

Spring and Spring Boot are different things

The Spring Framework is a toolbox. Its core is a container that creates your objects and connects them (inversion of control), and around that core sit modules for web (Spring MVC), data access, transactions, messaging, testing and more. The framework is deliberately unopinionated: it can run inside a servlet container, in a desktop program or in a test, and it leaves almost every choice to you.

That freedom had a price. A classic Spring project began with a long list of decisions: which web server, which JSON library, which connection pool, which logging backend, which versions of fifty libraries work together. You wrote configuration for each of them before the first feature.

Spring Boot removes that start-up cost. It is not a new container and not a replacement for Spring; it is a layer of conventions on top. Boot gives you four things:

What Boot adds to Spring

Starters One dependency pulls in a tested set of libraries.
Auto-configuration Beans are created for you from what is on the classpath.
Embedded server The web server lives inside your jar.
Production features Health, metrics and logging come ready to use.

Everything Boot configures can be overridden.

1 / 2

The slogan is convention over configuration: Boot picks a sensible default for everything, and you override only what differs in your project.

The opinionated defaults

"Opinionated" means Boot makes choices so you do not have to. Add the web starter and you get Apache Tomcat as the embedded server, Spring MVC for request handling, Jackson for JSON and Logback for logging. Add the JPA starter and you get Hibernate and the HikariCP connection pool. Add nothing else and the application listens on port 8080, reads settings from application.properties or application.yml, and shuts down cleanly on Ctrl+C.

Those defaults are layered. Boot starts with its built-in value, then lets files, environment variables and command-line arguments override it, in a fixed order you will study in Properties, YAML and Externalized Config. The next TryIt models the idea with plain Java: a map of defaults, with your settings on top.

Java Defaults you can override

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

You wrote two lines and kept two defaults. That is the Boot experience: zero configuration to start, small configuration to adapt.

What a Boot application actually is

A Boot application is an ordinary Java program. There is no application server to install and no WAR file to deploy (though you can still build one). The web server is a library inside your jar, and java -jar app.jar starts everything.

The entire entry point of a real application looks like this:

Java
package com.example.demo;

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

@SpringBootApplication
public class DemoApplication {

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

That is real Spring Boot code, shown read-only. Two things do the work:

  • @SpringBootApplication marks this class as the configuration root. It switches on component scanning (find your annotated classes in this package and below) and auto-configuration (create infrastructure beans from the classpath). Lesson Component Scanning and Stereotypes takes it apart.
  • SpringApplication.run builds the container, runs auto-configuration, starts the embedded server if there is one, and keeps the program alive.

Inside run, Boot does roughly this: prepare the environment (read the configuration), print the banner, create the application context, register your beans, apply auto-configuration, refresh the context (instantiate singletons), start the web server and publish a "ready" event. The next TryIt is a stand-in that performs the same steps in miniature, using reflection to find a class annotated with our own @MiniBootApplication.

Java A bootstrap stand-in

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

What is real here: the idea of one annotated class as the root, a startup sequence, and beans created by the container rather than by your code. What is the stand-in: the real container is far richer (scopes, dependency injection, proxies, lifecycle callbacks, conditions), and the "server" here only prints a line.

Boot 3 versus Boot 4

You will meet more than one Boot version in real jobs, so know the dividing lines.

  • Boot 2.x (Spring Framework 5) used the javax.* packages and ran on Java 8. It is out of support; you only see it in legacy code.
  • Boot 3.x (Spring Framework 6) needs Java 17 or newer and moved from javax.* to the Jakarta EE namespace: jakarta.servlet, jakarta.persistence, jakarta.validation. Imports in old code break on upgrade for exactly this reason. Boot 3 also introduced GraalVM native image support and Micrometer-based observability.
  • Boot 4.x (Spring Framework 7) still runs on Java 17 as the minimum and supports newer Java releases up to the current LTS, builds on Jakarta EE 11, and splits its auto-configuration and starters into smaller, more focused modules. Jackson 3 is the default JSON library, and null-safety annotations moved to JSpecify.

The practical rule: a new project should start on the newest Boot release with the newest LTS Java, and this track follows Boot 4. Where Boot 3 differs in a way you will notice, the lessons say so.

Always check the compatibility notes of the exact Boot version you use. Names of starters and packages have moved between releases, and a lesson cannot replace the release notes of your version.

Spring, Spring MVC and Spring Boot compared

The three names are often mixed up, but they sit on different levels:

Spring Framework Spring MVC Spring Boot
What it is The core container and many modules (data access, transactions, messaging, testing) The web module of Spring, based on the servlet API A layer of conventions and tooling on top of Spring
Main job Create and wire objects (dependency injection) Map HTTP requests to controller methods and render responses Start a working application with almost no configuration
Configuration effort You choose and configure everything You configure the dispatcher servlet, view resolvers, message converters Starters and auto-configuration do it; you override only what differs
Web server None built in A servlet container you install and deploy into Embedded Tomcat, Jetty or Undertow inside your jar
Deployment Depends on the setup WAR file into an application server (traditionally) Executable jar with java -jar, or a container image
Use it for Any Java application The web part of any Spring application The default way to start a new Spring project

A Boot web application uses Spring MVC (or Spring WebFlux) and is a Spring application. Boot adds no new programming model: the @RestController and @Autowired you write are plain Spring MVC and Spring Framework.

The layers of a Boot application

Most Boot applications split their code into four layers. Each layer talks only to the one below it:

Four layers, one direction

Presentation Controllers handle HTTP and JSON.
Business Services hold the rules and transactions.
Persistence Repositories read and write entities.
Database Tables, indexes and constraints.

Requests go down, results come back up.

1 / 2
Layer Spring building blocks Responsibility Should not
Presentation @RestController, DTOs, validation, error handling Translate HTTP into method calls and back Contain business rules or touch the database
Business @Service, @Transactional (Transactions) Rules, calculations, coordination of several repositories Know about HTTP types such as HttpServletRequest
Persistence @Repository, Spring Data interfaces (Spring Data JPA), entities Store and load data Make business decisions
Database MySQL, PostgreSQL, H2 and so on Durable data and integrity
sequenceDiagram
    participant C as Client
    participant Ctl as BookController
    participant Svc as BookService
    participant Repo as BookRepository
    participant DB as Database
    C->>Ctl: GET /api/books/42
    Ctl->>Svc: find(42)
    Svc->>Repo: findById(42)
    Repo->>DB: select ... where id = 42
    DB-->>Repo: row
    Repo-->>Svc: Book entity
    Svc-->>Ctl: BookResponse (DTO)
    Ctl-->>C: 200 + JSON

A request travels down through the layers and the result comes back up; each layer converts the data to the shape the layer above expects.

Why bother? Each layer can be tested alone (a service test needs no web server), replaced (switch the database without touching controllers) and understood (you know where a rule lives). The usual mistakes are a controller that calls a repository directly, a service that returns entities with lazy collections to the web layer, and @Transactional placed on controllers instead of services.

Small applications sometimes organize by feature instead of by layer (book/BookController, book/BookService, book/BookRepository), which keeps related code together. The layering rule, "calls go down, not up", still applies inside each feature.

The stand-in below builds the four layers with plain Java and prints each hop of a request, so you can see the flow and the translation between entity and DTO. What is real: the responsibilities and direction of calls. What is the stand-in: no Spring, no HTTP and a Map instead of a database.

Java A request through four layers

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

Notice who decides what: the repository only reports "nothing found", the service turns that into a business exception, and the controller maps the exception to HTTP status 404. Each layer handles the concern that belongs to it.

Where Spring Boot fits

Boot is the default choice for Java back ends: REST APIs, server-rendered sites, batch jobs and microservices. It is a heavier tool than a lightweight framework for tiny scripts, and start-up time and memory use matter more in serverless settings, which is where native images (Native Images with GraalVM) come in. For a wider comparison of Spring, Jakarta EE and Boot, see the Spring Framework introduction.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the relationship between Spring Boot and the Spring Framework?

    Boot uses the same Spring container and modules. It adds starters, auto-configuration, an embedded server and production features, so you configure less.
  2. 2. What does @SpringBootApplication switch on?

    The annotation marks the configuration root, enables scanning of your own annotated classes and enables auto-configuration of infrastructure from the classpath.
  3. 3. Which change did Boot 3 bring compared with Boot 2?

    Boot 3 is built on Spring Framework 6, which requires Java 17 and uses the Jakarta EE namespace.
  4. 4. A project sets server.port=9090 in its properties file. What happens to the other defaults?

    Settings are layered. Your value overrides the one default it names, and every other default still applies.

Summary

  • Spring Boot is not a replacement for Spring; it adds starters, auto-configuration, an embedded server and production features on top of it.
  • Convention over configuration: Boot picks defaults and you override only what differs.
  • A Boot app is a normal Java program with one @SpringBootApplication class and a main that calls SpringApplication.run.
  • Boot 3 needs Java 17+ and uses jakarta.*; Boot 4 builds on Spring Framework 7 and Jakarta EE 11, and this track follows it.
  • Real Spring code in this track is read-only; the TryIt blocks are small plain-Java stand-ins.

Next: Creating a Project.