北京某大公司:SpringBean生命周期


《對線面試官》系列目前已經連載25篇啦!有深度風趣的系列!

關鍵源碼方法(強烈建議自己去擼一遍)

  • org.springframework.context.support.AbstractApplicationContext#refresh(入口)
  • org.springframework.context.support.AbstractApplicationContext#finishBeanFactoryInitialization(初始化單例對象入口)
  • org.springframework.beans.factory.config.ConfigurableListableBeanFactory#preInstantiateSingletons(初始化單例對象入口)
  • org.springframework.beans.factory.support.AbstractBeanFactory#getBean(java.lang.String)(萬惡之源,獲取並創建Bean的入口)
  • org.springframework.beans.factory.support.AbstractBeanFactory#doGetBean(實際的獲取並創建Bean的實現)
  • org.springframework.beans.factory.support.DefaultSingletonBeanRegistry#getSingleton(java.lang.String)(從緩存中嘗試獲取)
  • org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#createBean(java.lang.String, org.springframework.beans.factory.support.RootBeanDefinition, java.lang.Object[])(實例化Bean)
  • org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#doCreateBean(實例化Bean具體實現)
  • org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#createBeanInstance(具體實例化過程)
  • org.springframework.beans.factory.support.DefaultSingletonBeanRegistry#addSingletonFactory(將實例化后的Bean添加到三級緩存)
  • org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#populateBean(實例化后屬性注入)
  • org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#initializeBean(java.lang.String, java.lang.Object, org.springframework.beans.factory.support.RootBeanDefinition)(初始化入口)

去網上看博客的時候,找到了幾張比較好的圖,這里貼下方便大家理解吧~

來源:https://www.jianshu.com/p/6c359768b1dc

歡迎關注我的微信公眾號【Java3y】來聊聊Java面試

【對線面試官】系列 一周兩篇持續更新中!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM