SpringBoot (1.5.6.RELEASE) source code parsing (4 ),
Please respect the author's labor results, reprinted please indicate the original link: http://www.cnblogs.com/dylan-java/p/7468336.html
The previous article analyzed part of SpringApplication's run method, and then analyzed the remaining part.
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 }
Start your head and wait for time to continue writing.