0 votes
in Spring by
What is Spring Bean life cycle?

1 Answer

0 votes
by

Spring Beans are initialized by Spring Container and all the dependencies are also injected. When the context is destroyed, it also destroys all the initialized beans. This works well in most of the cases but sometimes we want to initialize other resources or do some validation before making our beans ready to use. Spring framework provides support for post-initialization and pre-destroy methods in spring beans.

We can do this by two ways – by implementing InitializingBean and DisposableBean interfaces or using init-method and destroy-method attribute in spring bean configurations. For more details, please read Spring Bean Life Cycle Methods.

Related questions

0 votes
asked Jul 27, 2020 in Spring by Robindeniel
0 votes
asked Jul 26, 2020 in Spring by SakshiSharma
...