springboot start logic analysis (b) Description of SpringApplication.run -------

It calls for the link:

    at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
    at com.ivy.demo.DemoApplication.main(DemoApplication.java:16)

Code:

public ConfigurableApplicationContext RUN (String ... args) { 
        the StopWatch StopWatch = new new the StopWatch (); 
     . // (. 1) the recording start time stopWatch.start (); ConfigurableApplicationContext context
= null ; Collection <SpringBootExceptionReporter> = exceptionReporters new new the ArrayList <> ( ); configureHeadlessProperty ();
     // (2) Get all SpringApplicationRunListener implementation class configuration, and encapsulated into SpringApplicationRunListeners class. SpringApplicationRunListeners the Listeners
= getRunListeners (args);
     . // (. 3) calls a list of listener methods starting listeners.starting ();
{the try ApplicationArguments applicationArguments = new new DefaultApplicationArguments ( args);
       . // (. 4) Prepare the environment ConfigurableEnvironment Environment
= prepareEnvironment (the Listeners, applicationArguments);
       . // (. 5) The configuration is ignored properties spring.beaninfo.ignore configureIgnoreBeanInfo (Environment);
       // (6) open to welcome the font. Banner printedBanner
= printBanner (Environment);
       . // (7) create ApplicationContext context
= createApplicationContext ();
       // (8) to get the error reporting class. exceptionReporters
= getSpringFactoriesInstances( SpringBootExceptionReporter.class, new Class[] { ConfigurableApplicationContext.class }, context); prepareContext(context, environment, listeners, applicationArguments, printedBanner); refreshContext(context); afterRefresh(context, applicationArguments); stopWatch.stop(); if (this.logStartupInfo) { new StartupInfoLogger(this.mainApplicationClass) .logStarted(getApplicationLog(), stopWatch); } listeners.started(context); callRunners(context, applicationArguments); } catch (Throwable ex) { handleRunFailure(context, ex, exceptionReporters, listeners); throw new IllegalStateException(ex); } try { listeners.running(context); } catch (Throwable ex) { handleRunFailure(context, ex, exceptionReporters, null); throw new IllegalStateException(ex); } return context; }

 

Guess you like

Origin www.cnblogs.com/itivy/p/11669174.html