public ConfigurableApplicationContext run(String... args) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); ConfigurableApplicationContext context = null; Collection<SpringBootExceptionReporter> exceptionReporters = new ArrayList<>(); //java.awt.headless=true configureHeadlessProperty(); // EventPublishingRunListener->SimpleApplicationEventMulticaster SpringApplicationRunListeners listeners = getRunListeners(args); /** LoggingApplicationListener * LiquibaseServiceLocatorApplicationListener * <-ApplicationStartingEvent& */ listeners.starting(); try { ApplicationArguments applicationArguments = new DefaultApplicationArguments(args); /** ApplicationPidFileWriter * FileEncodingApplicationListener * AnsiOutputApplicationListener * ConfigFileApplicationListener * DelegatingApplicationListener * ClasspathLoggingApplicationListener * LoggingApplicationListener * <-ApplicationEnvironmentPreparedEvent& */ ConfigurableEnvironment environment = prepareEnvironment(listeners,applicationArguments); configureIgnoreBeanInfo(environment); Banner printedBanner = printBanner(environment); context = createApplicationContext(); exceptionReporters = getSpringFactoriesInstances( SpringBootExceptionReporter.class, new Class[] { ConfigurableApplicationContext.class }, context); /** ApplicationPidFileWriter * ConfigFileApplicationListener * * LoggingApplicationListener <-ApplicationPreparedEvent */ prepareContext(context, environment, listeners, applicationArguments,printedBanner); //在这里createWebServer refreshContext(context); afterRefresh(context, applicationArguments); stopWatch.stop(); if (this.logStartupInfo) { new StartupInfoLogger(this.mainApplicationClass) .logStarted(getApplicationLog(), stopWatch); } // ApplicationStartedEvent& listeners.started(context); callRunners(context, applicationArguments); } catch (Throwable ex) { // ApplicationFailedEvent handleRunFailure(context, listeners, exceptionReporters, ex); throw new IllegalStateException(ex); } // ApplicationReadyEvent& listeners.running(context); return context; }
Spring Boot 源码02- 核心调度方法SpringApplication.run
猜你喜欢
转载自blog.csdn.net/wwhrestarting/article/details/79708645
今日推荐
周排行