spring
Bean Lifecycle in Spring?
The Spring Bean lifecycle is managed by the Spring Container.
- Instantiation: The container creates the bean instance.
- Populate Properties: Dependencies are injected.
- Aware Interfaces: If the bean implements
BeanNameAware,BeanFactoryAware, etc., those methods are called. - Post Processor (Before):
postProcessBeforeInitializationis called. - Initialisation:
afterPropertiesSet(InitializingBean) or custom init-method. - Post Processor (After):
postProcessAfterInitializationis called. - Ready: Bean is ready for use.
- Destruction:
destroy(DisposableBean) or custom destroy-method.