Life Cycle of Spring Beans

Beans Creation

  • Scan the application to create beans
  • Create beans and their dependencies

Invoke init()

  • Call initialization method (if configured)
  • Defined in three different ways for different configurations
  • Invoked once then bean and its dependencies are created

Use beans in Application

  • Using the beans in the application according to the requirements

Invoke destroy()

  • Call destroy method (if configured)
  • Defined in three different ways for different configurations
  • Invoked just before the application shutdown

For more details, visit this video.