As the old saying goes, “Teach a man to fish, and dependency injection will keep fresh fish coming,”1 dependency injection is the lifeblood of any serious enterprise Java application.
Dependency injection (DI) is the mechanism by which java objects are made available at specific points in your code by the
runtime. It’s an implementation of the
inversion of control (IoC) design pattern that makes it so that application code can be loosely coupled. So instead of non-DI code:
MyDependency myDependency = new MyDependency();
//some business logic
myDependency.cleanUp();
myDependency = null;
you ...