In a Spring application, the term life cycle applies to any class of application--Standalone Java, Spring Boot application, or Integration/System Test. Also, life cycle applies to all three dependency injection styles--XML, Annotations, and Java configuration. You define the configuration for beans as per business goals. But Spring creates these beans and manages the life cycle of the Spring beans. Spring loads the bean configurations either in Java or XML through ApplicationContext. After loading these beans, the Spring container handles the creation and instantiation of these beans as per your configuration. Let's divide the Spring application life cycle into three phases as follows:
- The initialization phase
- The Use phase
- The destruction phase
Please refer to the following diagram:
As you can see in the preceding diagram, each...