Circular Dependency in Spring | Bean Scope, Lazy & Eager Beans | Spring Boot Full Course #6

In this video, we will understand one of the most important Spring Core concepts: Circular Dependency. Before Spring creates any object, it first has to understand the dependency chain between beans. But what happens when two beans depend on each other? For example, `OrderService` needs `PaymentService`, and `PaymentService` also needs `OrderService`. That is where the circular dependency problem begins. In this lecture, we will understand this problem from first principles using both plain Java examples and Spring examples. We will see why constructor-based circular dependency fails, why setter or field injection may sometimes work, and why circular dependency is usually a sign of poor design. After that, we will move into Spring Bean Scopes and understand the difference between `singleton`, `prototype`, and web scopes like `request`, `session`, and `application`. Finally, we will understand **eager vs lazy initialization**, how `@Lazy` works, how Spring uses proxies for lazy dependencies, and how all of this connects with the Spring bean lifecycle. Topics covered in this video: Why bean creation order matters What is circular dependency? Circular dependency in plain Java Constructor injection circular dependency Setter and field injection circular dependency Spring’s early reference concept Why circular dependency is a design smell Singleton scope in Spring Prototype scope in Spring Prototype bean inside singleton bean Request, session, and application scopes Eager initialization Lazy initialization `@Lazy` annotation `@Lazy` on injection point Global lazy initialization in Spring Boot Bean lifecycle overview By the end of this video, you will clearly understand how Spring creates beans, how it manages their scope, when beans are initialized, and why circular dependency should be avoided in real-world applications. JAVA Beginner to Advance Series :    • Java Full Course 2026   Join System Design WhatsApp Group: https://www.whatsapp.com/channel/0029... Code and Notes: Github : https://github.com/adityatandon15/Spr... We have paid courses on DSA, Web Development , Blockchain, System Design & GenAI. Join Courses: https://strikes.in/ Coder Army Website: https://coderarmy.in/#home Coder Army App: https://play.google.com/store/apps/de... Connect with Aditya Tandon Instagram :   / adityatandon2   LinkedIn :   / adityatandon2   Twitter : https://x.com/adityatandon02 Timestamps: 00:00 Intro 00:29 Circular Dependency Introduction 15:40 Circular Dependency in Core Java 20:49 Field & setter Injection to solve C.D 30:15 Don't solve Circular Dependency, avoid it. 33:09 Removing Circular dependency in code 36:15 Bean Scopes (Singleton) 45:52 Prototype Scope 53:20 Singleton confusion with @Bean 56:49 When to use which scope 59:25 Other scopes Intro 01:00:17 Beans Initialization (Eager) 01:03:09 @Lazy Annotation & Initialization 01:05:15 Prorotype scope is Lazy 01:14:54 Why default scope is Eager 01:17:38 Solving Circular dependency using @Lazy

Paralyzed in shock: German industry bosses reap what they've sown!
▶︎

Paralyzed in shock: German industry bosses reap what they've sown!

Klaas schickt 3-Jährigen ALLEINE zum Bäcker | Experte für Alles
▶︎

Klaas schickt 3-Jährigen ALLEINE zum Bäcker | Experte für Alles

Spring IOC Container | Beans, @Component, @Autowired & @Bean | Spring Boot Full Course #5
▶︎

Spring IOC Container | Beans, @Component, @Autowired & @Bean | Spring Boot Full Course #5

Spring Boot & Spring Framework Full Course | Spring Boot Full Course #1
▶︎

Spring Boot & Spring Framework Full Course | Spring Boot Full Course #1

Dependency Injection & IoC Explained | Loose Coupling in Spring | Spring Boot Full Course #4
▶︎

Dependency Injection & IoC Explained | Loose Coupling in Spring | Spring Boot Full Course #4

What is Docker? Simply Explained by Shradha Ma'am
▶︎

What is Docker? Simply Explained by Shradha Ma'am

How to Start Coding | Programming for Beginners | Learn Coding | Intellipaat
▶︎

How to Start Coding | Programming for Beginners | Learn Coding | Intellipaat

Souparnika: 10-Year-Old Indian Girl STOPPED Mid-Song by Simon!
▶︎

Souparnika: 10-Year-Old Indian Girl STOPPED Mid-Song by Simon!

Learn To Think In Systems, It'll Put You Ahead Of 99% Of People
▶︎

Learn To Think In Systems, It'll Put You Ahead Of 99% Of People

her SAVAGE declutter led to this... 🤯
▶︎

her SAVAGE declutter led to this... 🤯

Parenting then vs. now: The hilarious reality
▶︎

Parenting then vs. now: The hilarious reality

The FULL VIDEO of Trump they didn’t want released
▶︎

The FULL VIDEO of Trump they didn’t want released

Master Apache Maven in one video | POM, Dependencies & Lifecycle | Spring Boot Full Course #3
▶︎

Master Apache Maven in one video | POM, Dependencies & Lifecycle | Spring Boot Full Course #3

Why I Resigned from My Werkstudent Job in Germany🇩🇪 | My Experience
▶︎

Why I Resigned from My Werkstudent Job in Germany🇩🇪 | My Experience

Fundamentals of Backend Architecture - How to Design Scalable Software
▶︎

Fundamentals of Backend Architecture - How to Design Scalable Software

We Are Sleeping All Wrong! The Science to Fix Your Sleep Cycle
▶︎

We Are Sleeping All Wrong! The Science to Fix Your Sleep Cycle

🔥 GOD UNLEASHES the Truth | Psalms 23, 35, 91 and 112 To Break Curses and Activate Abundance
▶︎

🔥 GOD UNLEASHES the Truth | Psalms 23, 35, 91 and 112 To Break Curses and Activate Abundance

Executor Framework Deep Dive | ThreadPool, Future & Callable | Java Full Course #56
▶︎

Executor Framework Deep Dive | ThreadPool, Future & Callable | Java Full Course #56

How 2 kids exposed CBSE’s biggest BLUNDER
▶︎

How 2 kids exposed CBSE’s biggest BLUNDER

🌸 Flowers Blooming Time-Lapse | Healing Music to Quiet the Mind & Calm the Soul
▶︎

🌸 Flowers Blooming Time-Lapse | Healing Music to Quiet the Mind & Calm the Soul