Spring vs Spring Boot Application Startup Flow
1. Traditional Spring Application Flow
1. JVM starts and main() method is invoked.
2. Developer manually creates ApplicationContext (XML or Java Config).
3. Spring loads configuration files or configuration classes.
4. Component scanning happens if explicitly enabled.
5. Bean definitions are created and stored in the container.
6. Singleton beans are instantiated eagerly.
7. Dependency Injection is performed (constructor, setter, field).
8. Bean lifecycle methods are executed (PostConstruct, afterPropertiesSet, init-method).
9. Beans are ready for use.
10. Application runs (external server if web application).
11. On shutdown, [Link]() is called.
12. Bean destruction callbacks are executed (PreDestroy, destroy-method).
2. Spring Boot Application Flow
1. JVM starts and main() method is invoked.
2. [Link]() is called.
3. Spring Boot sets up environment and loads [Link].
4. ApplicationContext is created automatically.
5. Auto-configuration is applied based on classpath.
6. Component scanning happens automatically.
7. Bean definitions are loaded into the container.
8. Singleton beans are instantiated.
9. Dependency Injection is performed.
10. Bean lifecycle methods are executed (same as Spring).
11. Embedded server (Tomcat/Jetty/Netty) is started.
12. Application becomes ready to serve requests.
13. On shutdown, Spring closes context and destroys beans.
Key Differences Summary
• Spring requires manual configuration and context creation.
• Spring Boot provides auto-configuration and embedded servers.
• Bean lifecycle is the same in both Spring and Spring Boot.
• Spring Boot reduces boilerplate code significantly.