SpringApplication:
Object[] sources) {
0) {
.asList(sources));
}
= deduceWebEnvironment();
// 从spring.factories里读取所有 ApplicationContextInitializer,并记入 SpringApplication
Collection) getSpringFactoriesInstances(
.class));
// 从spring.factories里读取所有 ApplicationListener,并记入 SpringApplication
.class));
= deduceMainApplicationClass();
}
.. args) {
StopWatch();
.start();
null;
null;
configureHeadlessProperty();
// 从spring.factories里读取所有 SpringApplicationRunListener,监听springboot启动,参考:org.springframework.boot.context.event.EventPublishingRunListener
= getRunListeners(args);
.starting();
try {
DefaultApplicationArguments(
args);
= prepareEnvironment(listeners,
applicationArguments);
= printBanner(environment);
// web环境下默认的 ApplicationContext: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
// 非web环境下默认的 ApplicationContext: org.springframework.context.annotation.AnnotationConfigApplicationContext
= createApplicationContext();
FailureAnalyzers(context);
// org.springframework.cloud.bootstrap.config.PropertySourceBootstrapProperties 会通过 ApplicationContextInitializer,准备 PropertySource
// PropertySourceBootstrapProperties 收集 PropertySourceLocator 来获得PropertySource
// 其中 org.springframework.cloud.config.client.ConfigServicePropertySourceLocator 是 Cloud Config Client 提供的 PropertySourceLocator
prepareContext(context, environment, listeners, applicationArguments,
printedBanner);
// 调用 context.refresh
refreshContext(context);
afterRefresh(context, applicationArguments);
null);
.stop();
.logStartupInfo) {
.mainApplicationClass)
.logStarted(getApplicationLog(), stopWatch);
}
return context;
}
Throwable ex) {
handleRunFailure(context, listeners, analyzers, ex);
IllegalStateException(ex);
}
}

相关文章: