Episode 1 | Spring vs Spring Boot — The Foundation
I'm starting a Spring Boot learning series where I'll follow this approach:
🔑 Keywords → 🧠 Understand → 💡 Why? → 💻 Practice → 🎯 Interview Questions → 🛠️ Project
For Episode 1, I started with the most basic question:
👉 What is Spring, and why do we need Spring Boot?
🔑 Keywords for This Episode
- Spring Framework
- Spring Boot
- Tight Coupling
- Loose Coupling
- Dependency
- IoC — Inversion of Control
- Dependency Injection
- Bean
1️⃣ What Is Spring Framework?
Spring Framework is a Java framework used to build applications, especially backend and enterprise applications.
But simply saying "Spring is a Java framework" doesn't really explain why we use it.
The better question is:
👉 Why do we need Spring?
Let's take a simple example from the application I'll be building while learning Spring Boot: an Employee Support / Service Request application.
A simplified structure might look like:
\
TicketController
↓
TicketService
↓
TicketRepository
↓
Database
\\
Here, TicketService needs TicketRepository to perform its job.
In plain Java, we could create that object ourselves:
\java
TicketRepository repository = new TicketRepository();
\\
This works perfectly fine for a small application.
But as an application grows, we can have hundreds of classes, and many classes may depend on other classes.
If every class is responsible for creating the objects it needs, the classes become strongly connected to their dependencies.
This is called:
🔴 Tight Coupling
2️⃣ What Is Tight Coupling?
Consider:
\
TicketService
↓
creates
↓
TicketRepository
\\
TicketService is directly responsible for creating TicketRepository.
Now imagine we want to:
- Change the implementation
- Replace the dependency
- Use a mock repository for testing
Because
TicketServicedirectly creates it, making those changes becomes harder. This is where: ### 🟢 Loose Coupling becomes important. We want a class to focus on: > "What do I need?" rather than: > "How do I create everything I need?"
3️⃣ How Does Spring Help?
Spring helps us manage objects and their dependencies.
Instead of:
\
TicketService
↓
creates
↓
TicketRepository
\\
we can have:
\
Spring
↓
creates & manages
↓
TicketRepository
↓
provides it to
↓
TicketService
\\
This leads us to two important Spring concepts:
- 🔹 IoC — Inversion of Control
- 🔹 Dependency Injection IoC means the responsibility for creating and managing objects is moved from our classes to Spring. Dependency Injection is how Spring provides the dependencies that a class needs. So the basic idea is:
\
Our classes need objects
↓
Spring manages those objects
↓
Spring provides them where needed
↓
Classes become more loosely coupled
\\
I'll dive deeper into these concepts in the next episode.
🫘 What Is a Spring Bean?
A Bean is simply an object that is created and managed by the Spring Container.
For example, if Spring creates and manages a TicketService object, that object is a Spring Bean.
Think of it like this:
\
TicketService class
↓
Spring creates an object
↓
Spring manages that object
↓
Spring Bean
\\
4️⃣ Then What Is Spring Boot?
Once I understood Spring, I had another question:
"If Spring already helps us build applications, why do we need Spring Boot?"
Spring applications can require configuration and setup.
Spring Boot was created to make building and running Spring applications easier.
The important thing to remember:
- ❌ Spring Boot does NOT replace Spring.
- ✅ Spring Boot is built ON TOP OF the Spring Framework. Think of it like this:
\
Spring Framework
↓
Core Spring functionality
↓
Spring Boot
↓
Easier setup & development
\\
Spring provides the foundation.
Spring Boot reduces the amount of configuration and setup we need.
5️⃣ Spring vs Spring Boot
🔵 Spring Framework
Spring provides the core functionality for building applications, including:
- IoC
- Dependency Injection
- Bean management
- Managing application objects and dependencies
🟢 Spring Boot
Spring Boot builds on Spring and simplifies application development through:
- Auto-configuration
- Starter dependencies
- Embedded servers
- Sensible defaults
- Less manual configuration The simplest way I remember it: > SPRING = FOUNDATION > SPRING BOOT = SIMPLIFIED WAY TO BUILD & RUN SPRING APPLICATIONS
6️⃣ Why Is Spring Boot Easier?
Imagine we want to build a web application.
There can be a lot of configuration and dependency setup involved. Spring Boot simplifies this.
For example, we can use starter dependencies for common application requirements. Spring Boot can also automatically configure many things based on our application's dependencies and configuration.
And for web applications, Spring Boot can provide an embedded server such as Tomcat.
So instead of spending a lot of time setting up the infrastructure, we can focus more on building the actual application.
I'll explore:
- Auto-configuration
- Starter Dependencies
- Embedded Server
- Tomcat in the Spring Boot episode.
7️⃣ The Big Picture
The biggest thing I learned in Episode 1:
Spring and Spring Boot aren't two completely separate technologies. They are connected.
\
Spring Framework
↓
Core Spring functionality
↓
IoC + Dependency Injection
↓
Object & dependency management
↓
Spring Boot
↓
Simplifies configuration & setup
↓
Easier Spring application development
\\
Before learning individual annotations, I wanted to understand the WHY behind Spring Boot.
📌 NEXT 2 EPISODES
This episode was just the foundation.
I intentionally introduced some keywords without going deep into them because I want to learn each concept separately.
🌱 Episode 2 — Spring Core
We'll break down:
- IoC — Inversion of Control
- Dependency
- Dependency Injection
- Spring Container
- Bean
- ApplicationContext
- Component Scanning
🚀 Episode 3 — Spring Boot
We'll break down:
- Auto-configuration
- Starter Dependencies
- Embedded Server
- Tomcat
@SpringBootApplicationSpringApplication.run()
So if you saw some of these keywords in Episode 1 and thought,
"What does that mean?"
That's exactly what the next two episodes are for.
One concept at a time. One project throughout the journey.
Top comments (0)