1、初始化

2、run

2.1、StopWatch

2.2、getRunListeners().starting()

2.3、prepareEnvironment

2.4、printBanner

2.5、createApplicationContext()

2.6、refreshContext(context)

2.7、refreshContext(context)

2.8、afterRefresh(context, applicationArguments)

2.9、listeners.finished(context, null)

附录-run

public ConfigurableApplicationContext run(String... args) {
// 2.1、StopWatch
StopWatch stopWatch = new StopWatch();
stopWatch.start();
ConfigurableApplicationContext context = null;
FailureAnalyzers analyzers = null;
// 2.2
configureHeadlessProperty();
// 2.3 getRunListeners().starting()
SpringApplicationRunListeners listeners = getRunListeners(args);
listeners.starting();
try {
// 2.4、prepareEnvironment
ApplicationArguments applicationArguments = new DefaultApplicationArguments(
args);
ConfigurableEnvironment environment = prepareEnvironment(listeners,
applicationArguments);
// 2.5 打印 Spring Boot logo
Banner printedBanner = printBanner(environment);
// 2.6 创建ApplicationContext
context = createApplicationContext();
analyzers = new FailureAnalyzers(context);
// 2.7
prepareContext(context, environment, listeners, applicationArguments,
printedBanner);
// 2.8
refreshContext(context);
// 2.9
afterRefresh(context, applicationArguments);
// 2.10
listeners.finished(context, null);
stopWatch.stop();
if (this.logStartupInfo) {
new StartupInfoLogger(this.mainApplicationClass)
.logStarted(getApplicationLog(), stopWatch);
}
return context;
}
catch (Throwable ex) {
handleRunFailure(context, listeners, analyzers, ex);
throw new IllegalStateException(ex);
}
}