How SpringApplication.run() Bootstraps a Spring Boot App: A Technical Deep Dive
Every Spring Boot application starts when SpringApplication.run() is called from the main() method, triggering a multi-step startup sequence. Internally, the static run() method first creates a SpringApplication instance — where all configuration occurs — before invoking the instance-level run() for execution. During construction, Spring Boot deduces the web application type (SERVLET, REACTIVE, or NONE) by scanning the classpath for relevant classes. It also loads ApplicationContextInitializers and ApplicationListeners from META-INF/spring.factories, assigning each a distinct role in configuring the context or reacting to application events. For advanced use cases, developers can manually instantiate SpringApplication or use SpringApplicationBuilder to customize settings or build parent-child context hierarchies before startup.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.




Discussion (0)
Log in to join the discussion and vote.
Log in