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?
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?
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.
1非プライベートコンストラクターが定義されていて、同じものが構成メタデータで宣言されている場合、クラスはリフレクションを使用してインスタンス化されます。getDeclaredConstructor()
クラス APIの
セクション4.3.2SpringドキュメントからのBeanのインスタンス化をお読みください