請尊重作者勞動成果,轉載請標明原文鏈接:http://www.cnblogs.com/dylan-java/p/7468336.html 上一篇分析了SpringApplication的run方法的一部分,接下來繼續分析剩下的部分 先起個頭,等有時間了再繼續寫 ...
請尊重作者勞動成果,轉載請標明原文鏈接:http://www.cnblogs.com/dylan-java/p/7468336.html
上一篇分析了SpringApplication的run方法的一部分,接下來繼續分析剩下的部分
1 public ConfigurableApplicationContext run(String... args) { 2 StopWatch stopWatch = new StopWatch(); 3 stopWatch.start(); 4 ConfigurableApplicationContext context = null; 5 FailureAnalyzers analyzers = null; 6 configureHeadlessProperty(); 7 SpringApplicationRunListeners listeners = getRunListeners(args); 8 listeners.starting(); 9 try { 10 ApplicationArguments applicationArguments = new DefaultApplicationArguments( 11 args); 12 ConfigurableEnvironment environment = prepareEnvironment(listeners, 13 applicationArguments); 14 Banner printedBanner = printBanner(environment); 15 context = createApplicationContext(); 16 analyzers = new FailureAnalyzers(context); 17 prepareContext(context, environment, listeners, applicationArguments, 18 printedBanner); 19 refreshContext(context); 20 afterRefresh(context, applicationArguments); 21 listeners.finished(context, null); 22 stopWatch.stop(); 23 if (this.logStartupInfo) { 24 new StartupInfoLogger(this.mainApplicationClass) 25 .logStarted(getApplicationLog(), stopWatch); 26 } 27 return context; 28 } 29 catch (Throwable ex) { 30 handleRunFailure(context, listeners, analyzers, ex); 31 throw new IllegalStateException(ex); 32 } 33 }
先起個頭,等有時間了再繼續寫