bean lifecycle

The stages a Spring bean passes through: construction, dependency injection, initialization, use, and destruction when the context closes.

In more detail

Put preparation in an initialization callback after injection, not in a constructor that may see incomplete framework state. Put cleanup in a destruction callback, and only for resources this bean owns. Order between beans follows their dependencies; explicit ordering should be rare.

Related terms

Taught in

References