Reputation: 53
I learned that when IoC container initializes, it creates instances and injects the dependencies.
How does it create the objects? Is it creating them using the new operator?
Upvotes: 2
Views: 1544
Reputation: 2711
1 Classes if they have a non-private constructor defined and same is declared in configuration metadata, are instantiated using reflection. getDeclaredConstructor()
of a class API
Please read section 4.3.2 Instantiating beans from spring documentation
Upvotes: 0
Reputation: 120781
In Java the only way to instanciate an object, is to call a constructor.
You can call the constructor using the new
operator or by reflection.
Spring use reflection to instanciate an object.
Upvotes: 2