#SpringBoot #SpringBeanScopes #SingletonVsPrototype
Lecture 6 – Bean Scopes Inside Each Other (Singleton & Prototype)
In this lecture, we deep dive into one of the most confusing and most important concepts in Spring Boot —
using one bean scope inside another.
You will clearly understand:
Prototype inside Singleton
Singleton inside Prototype
Why state leaks happen
When special handling is required
Real-world design decisions used in industry
This lecture focuses on concepts + architecture, not just syntax.
Timestamps:
00:00 - Intro & Course Roadmap
02:52 - Agenda
05:00 - Recap
06:15 - Prototype inside Singleton
12:45 - Problem?
13:35 - Cause of problem
15:10 - 1. Solve using ObjectProvider
19:42 - 2. @Lookup
22:25 - Real World use cases
25:18 - Singleton inside prototype?
34:20 - Summary
🧠 What You’ll Learn in This Video
✔ Why injecting prototype directly into singleton fails
✔ How ObjectProvider solves prototype-in-singleton problem
✔ How singleton inside prototype works safely
✔ Real-world report generation example
✔ How state leakage happens and how to avoid it
✔ When to use singleton vs prototype in real applications
✔ UML / architecture diagrams for clarity
🧩 Topics Covered
Spring Bean Scopes Recap
Singleton inside Prototype
Prototype inside Singleton
State leakage explained
Service vs Worker pattern
Real-world report generator example
Common configuration as singleton
All 4 scope combinations summary
🎯 Who This Lecture Is For?
Beginners learning Spring Boot properly
Developers confused about Singleton vs Prototype
Interview preparation (very commonly asked topic)
Anyone building real Spring applications
📌 Course Information
This video is part of the Spring Boot 0→∞ (Zero to Infinity) Course,
where we learn Spring Boot from fundamentals to advanced internal concepts, step by step.
👉 Make sure to watch previous lectures for full context.
🔔 Stay Connected
If you found this lecture useful:
📌 Save it for revision
💬 Comment your doubts — I reply to every genuine question
#PrototypeBean #SingletonBean #SpringCore #Java #BackendDevelopment #Codersphile