?
?
?
?
?
?
?
?
?
?
SpringApplication:SpringBoot程序啟動的一站式解決方案
深入探索SpringApplication執行流程
因為書上的版本是1.2的,比較老,這里參考http://blog.csdn.net/zxzzxzzxz123/article/details/69941910
?
public ConfigurableApplicationContext run(String... args) {StopWatch stopWatch = new StopWatch();stopWatch.start();ConfigurableApplicationContext context = null;FailureAnalyzers analyzers = null;configureHeadlessProperty();SpringApplicationRunListeners listeners = getRunListeners(args);listeners.starting();try {ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);ConfigurableEnvironment environment = prepareEnvironment(listeners,applicationArguments);Banner printedBanner = printBanner(environment);context = createApplicationContext();analyzers = new FailureAnalyzers(context);prepareContext(context, environment, listeners, applicationArguments,printedBanner);refreshContext(context);afterRefresh(context, applicationArguments);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);}}
?
SpringApplicationRunListener
SpringApplicationRunListener是一個只有SpringBoot應用的main方法執行過程中接收不同執行時點時間通知的監聽者
ApplicationListener
ApplicationContextInitializer
?
?
CommandLineRunner
?