Home >Java >javaTutorial >spring-: spring-boot-bootstrapping-behind-the-scenes
I. Spring Boot Application Step
<.> 1.1 JVM startup and the main class load
Java virtual machine (JVM) starts and loads the main class containing the
method.public static void main(String[] args)
<.> 1.2 Execution
SpringApplication.run()
Execute the method to start the Spring Boot application. This is the entrance point for all Spring Boot applications.
SpringApplication.run()
Initialization, including:
SpringApplication
Judgment application type (web or non -web).
SpringApplication
If it is a web application, use the context based on the service (such as ). ApplicationContext
AnnotationConfigServletWebServerApplicationContext
Load the registered
<.> 1.6 Detect and apply ApplicationContextInitializer
ApplicationContextInitializer
implementation, allowing external listeners to receive application startup notifications. <.> 1.7 Preparing the environment (attributes, configuration files and configuration) SpringApplicationRunListener
SpringApplicationRunListener
<.> 1.8 Refresh the context
application.properties
application.yml
Scanning belt includes categories of instantiated bean and manage its life cycle.
Application dependency injection and analytical dependence relationship.@Component
<.> 1.9 Start the embedded web server (if applicable) @Service
@Repository
@Controller
If there is a bean of
<.> 1.11 triggers Incident
In order to remember the startup process, it can be regarded as three main stages:
JVM start the application.
Scan, create and inject bean.
The application is fully running and waiting for the request. ?
CommandLineRunner
ApplicationRunner
<.> 1.12 Keep application operation (for web applications) ApplicationReadyEvent
Create and refresh the context. SpringApplication.run()
2️🎜 The initialization stage of the context
.
The above is the detailed content of spring-: spring-boot-bootstrapping-behind-the-scenes. For more information, please follow other related articles on the PHP Chinese website!