当前位置: 首页 > wzjs >正文

网站建设hnshangtian郑州市招投标信息网

网站建设hnshangtian,郑州市招投标信息网,wordpress 中国 替代,商铺设计Spring启动流程 随着springboot的功能越来越强大,我们逐渐忘记了spring,但是每当遇到问题时缺无从下手, 我们在享受springboot给我们带来的便利的同时更应该了解其底层原理,知其然更要知其所以然,下面我们一起进入spr…

Spring启动流程

随着springboot的功能越来越强大,我们逐渐忘记了spring,但是每当遇到问题时缺无从下手,
我们在享受springboot给我们带来的便利的同时更应该了解其底层原理,知其然更要知其所以然,下面我们一起进入spring的世界探索吧

Spring启动

我们从springboot的入口(不使用springboot的方式放在后面文章讲解)来看spring是如何被启动的
我们都有启动类如下

AttachCode

@SpringBootApplication
public class Main {public static void main(String[] args) {SpringApplication.run(Main.class, args);}

我们先来看下SpringApplication.run(Main.class, args);我们今天的主要内容不是springboot,所以我们一路跟踪到spring的refesh方法

AttachCode

   public static ConfigurableApplicationContext run(Class<?>[] primarySources, String[] args) {return (new SpringApplication(primarySources)).run(args);}

AttachCode

public void refresh(){
//省略部分代码
this.refreshContext(context);
//省略部分代码
}

AttachCode

    private void refreshContext(ConfigurableApplicationContext context) {if (this.registerShutdownHook) {shutdownHook.registerApplicationContext(context);}this.refresh(context);}

今天的主角AttachCode

@Overridepublic void refresh() throws BeansException, IllegalStateException {synchronized (this.startupShutdownMonitor) {StartupStep contextRefresh = this.applicationStartup.start("spring.context.refresh");// Prepare this context for refreshing.prepareRefresh();// Tell the subclass to refresh the internal bean factory.ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();// Prepare the bean factory for use in this context.prepareBeanFactory(beanFactory);try {// Allows post-processing of the bean factory in context subclasses.postProcessBeanFactory(beanFactory);StartupStep beanPostProcess = this.applicationStartup.start("spring.context.beans.post-process");// Invoke factory processors registered as beans in the context.invokeBeanFactoryPostProcessors(beanFactory);// Register bean processors that intercept bean creation.registerBeanPostProcessors(beanFactory);beanPostProcess.end();// Initialize message source for this context.initMessageSource();// Initialize event multicaster for this context.initApplicationEventMulticaster();// Initialize other special beans in specific context subclasses.onRefresh();// Check for listener beans and register them.registerListeners();// Instantiate all remaining (non-lazy-init) singletons.finishBeanFactoryInitialization(beanFactory);// Last step: publish corresponding event.finishRefresh();}catch (BeansException ex) {if (logger.isWarnEnabled()) {logger.warn("Exception encountered during context initialization - " +"cancelling refresh attempt: " + ex);}// Destroy already created singletons to avoid dangling resources.destroyBeans();// Reset 'active' flag.cancelRefresh(ex);// Propagate exception to caller.throw ex;}finally {// Reset common introspection caches in Spring's core, since we// might not ever need metadata for singleton beans anymore...resetCommonCaches();contextRefresh.end();}}}

今天我们先到这里


本文由 idea的插件"AnNote"协助完成,是一款源码学习笔记,不但能够帮助我们做笔记、分享笔记还可以学习学霸的笔记。欢迎大家试用


文章转载自:

http://ubzIMaS3.mhgpz.cn
http://WqyG1NlP.mhgpz.cn
http://UcKVrXNS.mhgpz.cn
http://WAJAFftg.mhgpz.cn
http://t2jXvuk9.mhgpz.cn
http://0Y6MPyIy.mhgpz.cn
http://OoM5ACll.mhgpz.cn
http://IgFQCdo4.mhgpz.cn
http://2gtAcfgx.mhgpz.cn
http://vT9xNXvu.mhgpz.cn
http://fWqqD2tn.mhgpz.cn
http://IqW5c17f.mhgpz.cn
http://8xi42643.mhgpz.cn
http://oBGtHafo.mhgpz.cn
http://2Is4BtRM.mhgpz.cn
http://6lfRKpMh.mhgpz.cn
http://ACCvVIX4.mhgpz.cn
http://lOHQDCjN.mhgpz.cn
http://aTGC9yUy.mhgpz.cn
http://VIFwsv78.mhgpz.cn
http://sCPwQhXw.mhgpz.cn
http://srvGfZMo.mhgpz.cn
http://4ZhpSpny.mhgpz.cn
http://UacyfkmT.mhgpz.cn
http://BGiEwzGD.mhgpz.cn
http://obzirdbU.mhgpz.cn
http://fIWm6ZVe.mhgpz.cn
http://pjdfZPCi.mhgpz.cn
http://GzrYbT4O.mhgpz.cn
http://bzBpBVGP.mhgpz.cn
http://www.dtcms.com/wzjs/734705.html

相关文章:

  • 网站备案密码重置seo网站建设课程
  • 江西省建设职业培训学校网站西安做公司网站的公司
  • 怎么做内网网站wordpress萌主题下载地址
  • 网站的建设流程图沈阳网页模板建站
  • 软膜做网站有用吗注册一个公司网站的费用
  • 网站建设公司知名推荐网站制作公司
  • 横沥东莞网站建设为什么企业要建设自己的企业文化
  • 赣州制作网站百度湖南省军区强军网网站群建设项目
  • 八步网站建设wordpress 买数据库
  • 焦作做微信网站多少钱wordpress商用收费不
  • 河南省汝州市文明建设门户网站企业网站发布图片文章
  • 学校建设评建工作网站网站 模板 php
  • 做宣传的网站网站建设流程报价
  • 购物网站每个模块主要功能免费图表制作网站
  • ppt做长图网站网店推广目的
  • 网站怎么做跟踪链接自己做的网站放在服务器哪里
  • 申请免费网站主页空间广州市专业做网站
  • 买卖域名的网站好网络科技公司网站制作
  • ae做动画教程网站十大软件排行榜
  • 网络营销的原理南阳网站优化公司
  • 石家庄知名网站网站建设系统公司地址
  • 企业官网网站模板下载不了网站开发和运行模式的搭建
  • 团购网站模板下载太原制作网站企业
  • 建设服装网站wordpress+vps+配置
  • 做网站是什么会计科目电子商务网站推广怎么做
  • 全国加盟网站大全做外贸怎么进入国外的网站
  • 推广做黄页网站城阳网站建设培训
  • 做试试彩网站wordpress怎么seo好
  • 求个免费网站打不开wordpress的登陆界面
  • 淘宝客建站模板网站维护源码自适应