Skip to content
José da Cruz

Enterprise Architect, and Life Thinker

José da Cruz

Enterprise Architect, and Life Thinker

Learning Spring Boot from Zero to Cloud: Part 28 – Scope Prototype, ApplicationContext, ObjectFactory

josedacruz, May 9, 2025May 9, 2025

In this video, we take a comprehensive look at prototype scope in Spring Boot, when and how to use it, and the best practices around injecting prototype-scoped beans into singleton-scoped components. This is part of a growing series, so make sure to check the playlist for more hands-on Spring Boot topics!

🔥 Whether you’re a backend developer optimizing multi-threaded jobs, or trying to manage bean lifecycle more effectively, this session will give you both the theory and practical code examples to master @Scope("prototype").

👇 What you’ll learn in this video:
🔍 The difference between singleton and prototype scopes
🎯 Real-world use cases where prototype makes sense
⚙️ How ObjectFactory<T> and ApplicationContext differ and when to use each
🛠️ Step-by-step: injecting prototype beans correctly
📊 Detailed comparisons and clean code samples
🚨 What not to do: common pitfalls and performance concerns

⏱️ Timestamps
00:00 – Introduction, Scopes in Spring
01:53 – Prototype Scope: What is it?
03:37 – Why Use Prototype Scope?
04:20 – Singleton vs Prototype Scope (visualization)
04:45 – Drawbacks of Prototype Scope
06:34 – Real-World Example: Report Generation
08:13 – Creating a Prototype Bean
09:45 – Problem: Prototype in Singleton
11:32 – Using ObjectFactory for Lazy Injection
12:52 – ApplicationContext – Full Spring Container
16:55 – @Configuration and @Bean – Prototype Scope
17:30 – @Component and @Scope – Prototype Scope
19:16 – Best Practices
21:22 – Summary
22:22 – Code Walkthrough

📂 GitHub Repository with All Code Examples:
👉 https://github.com/josedacruz/youtube-springboot


💬 Have a question or need clarification? Drop it in the comments!
👍 Like, 🔁 share, and 🔔 subscribe so you don’t miss the next episode.

Related

spring-boot

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • architecture (154)
  • artificial-intelligence (6)
  • books (2)
  • courses (4)
  • decision-frameworks (4)
  • finances (1)
  • java (8)
  • life-improvement (20)
  • metrics (3)
  • observability (2)
  • puzzles and challenges (3)
  • reviews (1)
  • security (8)
  • spring-boot (36)
  • Systems Thinking (3)
  • GitHub Weekly: MCP Tools Trending Right Now (September 28 – October 4, 2026)
  • The Bulkhead Pattern: Why One Slow Dependency Shouldn’t Sink the Whole Ship
  • Essential Reading: A Philosophy of Software Design — Fighting Complexity One Module at a Time
  • GitHub Weekly: Top 10 Trending Repos (September 21 – September 27, 2026)
  • The Volunteer Tax: Why Raising Your Hand in a Meeting Makes You the Permanent Owner
©2026 José da Cruz | WordPress Theme by SuperbThemes