Dependency Injection (DI) in Spring

After getting an idea of how Spring manages bean life cycle, next we will learn how Spring provides and maintains the dependencies in your application.

DI is a process of providing the dependent objects to other objects that need it. In Spring, the container supplies the dependencies. The flow of creating and managing the dependencies is inverted from client to container. That is the reason we call it an IoC container.

A Spring IoC container uses the Dependency Injection (DI) mechanism to provide the dependency at runtime. In Chapter 1Why Dependency Injection?, we saw various DI types such as constructor, setter method, and interface-based. Let's see how we can implement the constructor and setter-based DI through Spring's IoC container.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.52.188