Spring IoC Container Explained

❓ What actually happens inside Spring when our application starts? Day 2 of learning Spring Framework deeply 🌱 Today I explored the core concept behind Spring — IoC (Inversion of Control). Earlier, developers were responsible for creating and managing objects, but with Spring, this responsibility is handled by the IoC Container, improving flexibility and maintainability. Here’s what I learned today: 🔹 Types of IoC Containers BeanFactory → Lazy loading (bean created only when requested using getBean()) ApplicationContext → Eager loading (creates beans at application startup) 🔹 Lazy Initialization Using lazy-init="true" allows beans in ApplicationContext to be created only when needed. 🔹 Bean Scopes Singleton → Same instance returned every time (default) Prototype → New instance created for each request 🔹 Key Insight Prototype beans are instantiated on demand, making them behave similarly to lazy initialization. Understanding how Spring manages objects internally is helping me connect theory with real backend architecture. Continuing to build strong Core Spring fundamentals before moving toward Spring Boot 🚀 #SpringFramework #Java #BackendDevelopment #LearningInPublic #SoftwareEngineering

To view or add a comment, sign in

Explore content categories