SpringBoot启动过程核心源码解析
2022-05-23 17:33:00 7 举报
AI智能生成
SpringBoot启动过程核心源码解析
作者其他创作
大纲/内容
应用入口
StopWatch stopWatch = new StopWatch();stopWatch.start();
SpringApplicationRunListeners listeners = getRunListeners(args);
void starting() { for (SpringApplicationRunListener listener : this.listeners) { listener.starting(); } }
listeners.start();
ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);
private ConfigurableEnvironment getOrCreateEnvironment() { if (this.environment != null) { return this.environment; } switch (this.webApplicationType) { case SERVLET: return new StandardServletEnvironment(); case REACTIVE: return new StandardReactiveWebEnvironment(); default: return new StandardEnvironment(); } }
class SpringApplicationRunListeners {void environmentPrepared(ConfigurableEnvironment environment) { for (SpringApplicationRunListener listener : this.listeners) { listener.environmentPrepared(environment); } }}
protected void bindToSpringApplication(ConfigurableEnvironment environment) { try { Binder.get(environment).bind(\"spring.main\
private void configureIgnoreBeanInfo(ConfigurableEnvironment environment) { if (System.getProperty(CachedIntrospectionResults.IGNORE_BEANINFO_PROPERTY_NAME) == null) { Boolean ignore = environment.getProperty(\"spring.beaninfo.ignore\
configureIgnoreBeanInfo(environment);
Banner printedBanner = printBanner(environment);
protected ConfigurableApplicationContext createApplicationContext() { Class<?> contextClass = this.applicationContextClass; if (contextClass == null) { try { switch (this.webApplicationType) { case SERVLET: contextClass = Class.forName(DEFAULT_SERVLET_WEB_CONTEXT_CLASS); break; case REACTIVE: contextClass = Class.forName(DEFAULT_REACTIVE_WEB_CONTEXT_CLASS); break; default: contextClass = Class.forName(DEFAULT_CONTEXT_CLASS); } } catch (ClassNotFoundException ex) { throw new IllegalStateException( \
ConfigurableApplicationContext context = createApplicationContext();
class SpringApplicationRunListeners {void contextPrepared(ConfigurableApplicationContext context) { for (SpringApplicationRunListener listener : this.listeners) { listener.contextPrepared(context); } }}
class SpringApplicationRunListeners {void contextLoaded(ConfigurableApplicationContext context) { for (SpringApplicationRunListener listener : this.listeners) { listener.contextLoaded(context); } }}
protected void refresh(ConfigurableApplicationContext applicationContext) { applicationContext.refresh(); }
private void refreshContext(ConfigurableApplicationContext context) { refresh((ApplicationContext) context); if (this.registerShutdownHook) { try { context.registerShutdownHook(); } catch (AccessControlException ex) { // Not allowed in some environments. } } }
refreshContext(context);
stopWatch.stop();
class SpringApplicationRunListeners {void started(ConfigurableApplicationContext context) { for (SpringApplicationRunListener listener : this.listeners) { listener.started(context); } }}
listeners.started(context);
class SpringApplicationRunListeners {void running(ConfigurableApplicationContext context) { for (SpringApplicationRunListener listener : this.listeners) { listener.running(context); } }}
listeners.running(context);
public ConfigurableApplicationContext run(String... args)
解析SpringApplication
SpringBoot启动过程核心源码解析
0 条评论
回复 删除
下一页