请尊重作者劳动成果,转载请标明原文链接: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 }
先起个头,等有时间了再继续写
时间: 2024-10-29 10:46:19