Vishnu B
Posted on Nov 1
Fully Autonomous
If you have written any Spring Boot code, you have seen this: a class asks for another class in its constructor, and somehow the right object is just there. Nobody called new . Nobody looked anything up. Let's see who does that work, with plain words and a tiny Spring Boot app you can run yourself.
The idea in one minute
You mark classes with annotations like @Service or @Component .
When the app starts, Spring Boot scans your code and creates an object of each one. These managed objects are called beans , and they live in the Spring container (the ApplicationContext ).
When a bean's constructor asks for another bean, the container passes it in. That passing-in is dependency injection .
The Spring documentation calls this Inversion of Control: instead of your object building or finding its own helpers, the container creates them and hands them over.…