Spring Boot Full Course 2026

Complete Spring 7 & Spring Boot 4 course from beginner to Advance using first thought principle.

Curated by: Coder Army (29 videos)


Currently Playing: 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 : https://youtube.com/playlist?list=PLQEaRBV9gAFsR15tNo2QLF9d2qc-c018p&si=lNuF5lyt4nKz9Up7 Join System Design WhatsApp Group: https://www.whatsapp.com/channel/0029VbBF1XKF1YlMyYuPM23s Code and Notes: Github : https://github.com/adityatandon15/Spring-Framework-Full-Course 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/details?id=com.rohit.negi Connect with Aditya Tandon Instagram : https://www.instagram.com/adityatandon2 LinkedIn : https://www.linkedin.com/in/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


Tracks in this Playlist