What Is Spring? What Is Spring Boot?

Overview

If you’ve never used Spring, read this first. The rest of the track uses words like bean, IoC, and auto-configuration constantly — this page explains what they mean before you see them again.

You only need to know Java (classes, constructors, packages). You do not need to know Spring yet.


Table of contents

  1. The problem Spring solves
  2. Spring Framework — what it gives you
  3. Spring Boot — what it adds
  4. What happens when you run a Spring Boot app
  5. Glossary
  6. Interview questions
  7. Summary

1. The problem Spring solves

In plain Java, your main method builds every object by hand:

var repo = new OrderRepository(db);
var email = new EmailClient(config);
var service = new OrderService(repo, email);

This breaks down quickly:

  • Adding one class means editing main.
  • You decide manually whether to share or recreate objects (DB connection? one or per request?).
  • Tests need fakes passed through every constructor.
  • Configuration (port, URL, flags) gets sprinkled everywhere.

Spring’s idea: let a container create and wire your objects. Your classes only declare what they need.


2. Spring Framework — what it gives you

A container that holds beans

A bean is just an object Spring creates and manages for you (by default, one shared instance — a singleton). Your OrderService, PaymentService, etc. become beans.

Dependency injection (DI)

Instead of new OrderRepository() inside OrderService, you write a constructor:

public OrderService(OrderRepository orders) { this.orders = orders; }

Spring passes in the repository. That’s DI.

Cross-cutting features

Spring can wrap your methods to add behaviour without you copying code:

  • @Transactional — begin/commit/rollback a DB transaction.
  • Security — check if the caller is allowed.
  • Caching — remember return values.

Done via proxies (wrapper objects). The famous gotcha — calling a method on this skips the proxy — is covered in chapter 13.


3. Spring Boot — what it adds

If Spring Framework asks “how do I wire my app?”, Spring Boot answers “how do I get a working app with almost no config?”

Sensible defaults (auto-configuration)

If web libraries are on the classpath → start an embedded Tomcat on port 8080. If JPA + a DB driver → create a DataSource and wire Hibernate.

The rule is: if X is on the classpath and you haven’t defined your own bean, create a default one.

Starters

A starter is one Maven/Gradle dependency that pulls in a working set of libraries:

  • spring-boot-starter-web → Spring MVC + Jackson + Tomcat.
  • spring-boot-starter-data-jpa → Spring Data JPA + Hibernate.

One line in your build instead of hunting compatible versions.

One main class

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

SpringApplication.run starts the container, runs auto-configuration, scans for components, starts the embedded server.


4. What happens when you run a Spring Boot app

  1. JVM runs your main.
  2. SpringApplication.run creates an ApplicationContext — the registry of all beans.
  3. Auto-configuration runs, applying defaults that match your classpath.
  4. Component scanning finds @Component, @Service, @RestController, etc.
  5. Beans are created in dependency order.
  6. Embedded Tomcat starts (if it’s a web app).
  7. App stays alive until you stop the process.

5. Glossary

Word Plain meaning
Bean Object managed by Spring
IoC Container controls object creation, not your code
DI Dependencies are passed in (usually via constructor)
ApplicationContext The running container
Auto-configuration Default beans that turn on when conditions match
Starter A dependency that bundles related libraries
@SpringBootApplication @Configuration + auto-config + component scan

6. Interview questions

Q: What is Spring Boot in one line? A: Spring Framework + opinionated defaults + starters + embedded server, so you can run a JAR with java -jar and skip XML config.

Q: What does @SpringBootApplication do? A: Combines @Configuration, @EnableAutoConfiguration, and @ComponentScan on your main class.

Q: What is a bean? A: An object the Spring container creates, configures, and manages. Default scope is singleton.


7. Summary

Idea One line
Spring Container that creates and wires your objects
Spring Boot Spring + sensible defaults + starters
Auto-config Defaults that activate when classpath/properties match
Your @Bean Always overrides the default

Next step

Core IoC, DI, beans & lifecycle — goes one level deeper on beans and injection.


Happy Learning

Next: IoC, Dependency Injection, Beans & Lifecycle