源码


SpringBootConfiguration

springboot 注解 注解

注解

http://mp.weixin.qq.com/s?__biz=Mzg2MjEwMjI1Mg==∣=2247517350&idx=1&sn=96ab31817c899bd12254dda46b5c7e2f


public void **refresh() **throws **BeansException, IllegalStateException {
Object var1 = **this
.startupShutdownMonitor;
synchronized(this.startupShutdownMonitor) {
this.prepareRefresh();
ConfigurableListableBeanFactory beanFactory = this.obtainFreshBeanFactory();
this.prepareBeanFactory(beanFactory);

    **<font style="color:rgb(0, 0, 128);">try </font>**{
        **<font style="color:rgb(0, 0, 128);">this</font>**.postProcessBeanFactory(beanFactory);
        **<font style="color:rgb(0, 0, 128);">this</font>**.invokeBeanFactoryPostProcessors(beanFactory);
        **<font style="color:rgb(0, 0, 128);">this</font>**.registerBeanPostProcessors(beanFactory);
        **<font style="color:rgb(0, 0, 128);">this</font>**.initMessageSource();
        **<font style="color:rgb(0, 0, 128);">this</font>**.initApplicationEventMulticaster();
        **<font style="color:rgb(0, 0, 128);">this</font>**.onRefresh();
        **<font style="color:rgb(0, 0, 128);">this</font>**.registerListeners();
        **<font style="color:rgb(0, 0, 128);">this</font>**.finishBeanFactoryInitialization(beanFactory);
        **<font style="color:rgb(0, 0, 128);">this</font>**.finishRefresh();
    } **<font style="color:rgb(0, 0, 128);">catch </font>**(BeansException var9) {
        **<font style="color:rgb(0, 0, 128);">if </font>**(**<font style="color:rgb(0, 0, 128);">this</font>**.logger.isWarnEnabled()) {
            **<font style="color:rgb(0, 0, 128);">this</font>**.logger.warn(**<font style="color:rgb(0, 128, 0);">"Exception encountered during context initialization - cancelling refresh attempt: " </font>**+ var9);
        }

        **<font style="color:rgb(0, 0, 128);">this</font>**.destroyBeans();
        **<font style="color:rgb(0, 0, 128);">this</font>**.cancelRefresh(var9);
        **<font style="color:rgb(0, 0, 128);">throw </font>**var9;
    } **<font style="color:rgb(0, 0, 128);">finally </font>**{
        **<font style="color:rgb(0, 0, 128);">this</font>**.resetCommonCaches();
    }

}

}


public void refresh() throws BeansException, IllegalStateException &#123;
        Object var1 = this.startupShutdownMonitor;
        synchronized(this.startupShutdownMonitor) &#123;
            this.prepareRefresh();
            ConfigurableListableBeanFactory beanFactory = this.obtainFreshBeanFactory();
            this.prepareBeanFactory(beanFactory);

            try &#123;
                this.postProcessBeanFactory(beanFactory);
                this.invokeBeanFactoryPostProcessors(beanFactory);
                this.registerBeanPostProcessors(beanFactory);
                this.initMessageSource();
                this.initApplicationEventMulticaster();
                this.onRefresh();
                this.registerListeners();
                this.finishBeanFactoryInitialization(beanFactory);
                this.finishRefresh();
            &#125; catch (BeansException var9) &#123;
                if (this.logger.isWarnEnabled()) &#123;
                    this.logger.warn("Exception encountered during context initialization - cancelling refresh attempt: " + var9);
                &#125;

                this.destroyBeans();
                this.cancelRefresh(var9);
                throw var9;
            &#125; finally &#123;
                this.resetCommonCaches();
            &#125;

        &#125;
    &#125;

refresh()–>onRefresh()–>createWebServer()–>

private void createWebServer() &#123;
   WebServer webServer = this.webServer;
   ServletContext servletContext = getServletContext();
   if (webServer == null && servletContext == null) &#123;
      ServletWebServerFactory factory = getWebServerFactory();
      this.webServer = factory.getWebServer(getSelfInitializer());
   &#125;
   else if (servletContext != null) &#123;
      try &#123;
         getSelfInitializer().onStartup(servletContext);
      &#125;
      catch (ServletException ex) &#123;
         throw new ApplicationContextException("Cannot initialize servlet context",
               ex);
      &#125;
   &#125;
   initPropertySources();
&#125;

文章作者:   future
版权声明:   本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 future !
 上一篇
源码 源码
org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo#bindToThread 事务 https://www.toutiao
2021-06-19 future
下一篇 
心语 心语
【心语】最使人颓废的往往不是前途的坎坷,而是我们信心的丧失。当全世界都在说放弃的时候,坚定地告诉自己:再试一次!
2021-03-20 future
  目录