A Comprehensive Analysis of Spring Boot startup Process

  • 2020-07-21 08:18:27
  • OfStack

I've been very succinct, and I still haven't finished two articles (Spring Boot startup process (1) and spring Boot startup process (2). Here we go.

The method after refreshContext is afterRefresh, which is really... Good. Only callRunners1 methods are called within the afterRefresh method, which takes all the ApplicationRunner and CommandLineRunner interface implementation classes from the context and executes the run methods of those implementation classes. For example Spring Batch JobLauncherCommandLineRunner:


 @Override
 public void run(String... args) throws JobExecutionException {
  logger.info("Running default command line with: " + Arrays.asList(args));
  launchJobFromProperties(StringUtils.splitArrayElementsIntoProperties(args, "="));
 }

listeners.finished(context, null) actually publishes ApplicationReadyEvent events when exception is null.

Stop stopWatch. stop(), type the time in the log: Started Application in ***.462 seconds (JVM running for ***.977), and then feel the momentum of the throw:


 if (this.logStartupInfo) {
    new StartupInfoLogger(this.mainApplicationClass)
      .logStarted(getApplicationLog(), stopWatch);
   }

Finally, return context, and the run method is done.

==========================================================

I recently with github: https: / / github com/saaavsaaa


Related articles: