spring boot 启动过程 Spring Boot启动过程全面解析(三)

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

spring boot 启动过程 Spring Boot启动过程全面解析(三)

draculav   2021-03-24 我要评论
想了解Spring Boot启动过程全面解析(三)的相关内容吗,draculav在本文为您仔细讲解spring boot 启动过程的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:spring,boot,启动过程,下面大家一起来学习吧。

我已经很精简了,两篇(Spring Boot启动过程(一)spring Boot启动过程(二))依然没写完,接着来。

  refreshContext之后的方法是afterRefresh,这名字起的真...好。afterRefresh方法内只调用了callRunners一个方法,这个方法从上下文中获取了所有的ApplicationRunner和CommandLineRunner接口的实现类,并执行这些实现类的run方法。例如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)实际上是在exception为null的情况下发布了ApplicationReadyEvent事件。

  启动至此就差不多了,于是停止stopWatch.stop(),然后把时间打到日志里:Started Application in ***.462 seconds (JVM running for ***.977),然后感受下这记完就扔的气势:         

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

   最后返回个context,run方法就到此结束了。

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

咱最近用的github:https://github.com/saaavsaaa

以上所述是小编给大家介绍的Spring Boot启动过程全面解析(三),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们