The Dependency Lookup is an approach where we get the resource after demand. Various ways to get the resource are mentioned below:
Problems of Dependency Lookup
Tight coupling: The dependency lookup approach makes the code tightly coupled. If resource is changed, we need to perform a lot of modification in the code.
Not easy for testing: This approach creates a lot of problems while testing the application especially in black box testing.
Dependency Injection (DI) is a design pattern that removes the dependency from the code so that it can be easy to manage and test the application. It makes our programming code loosely coupled.
This process is fundamentally the inverse, hence the name Inversion of Control (IoC), of the bean itself controlling the instantiation or location of its dependencies by using direct construction of classes, or a mechanism such as the Service Locator pattern.
The org.springframework.beans and org.springframework.context packages are the basis for Spring Framework’s IoC container.