java spring 02. AbstractApplicationContext

spring創建對象的順序,先創建beanfactory,再會把xml文件讀取到spring。

public ClassPathXmlApplicationContext(String[] configLocations, boolean refresh, @Nullable ApplicationContext parent)throws BeansException {//調用父類的構造方法super(parent);//讀取配置文件路徑setConfigLocations(configLocations);if (refresh) {refresh();}}

在這里插入圖片描述
refresh:

public 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();}}}

01.prepareRefresh

protected void prepareRefresh() {// 設置開啟spring的時間this.startupDate = System.currentTimeMillis();//開關標志位this.closed.set(false);this.active.set(true);//日志信息if (logger.isDebugEnabled()) {if (logger.isTraceEnabled()) {logger.trace("Refreshing " + this);}else {logger.debug("Refreshing " + getDisplayName());}}// Initialize any placeholder property sources in the context environment.initPropertySources();// Validate that all properties marked as required are resolvable:// see ConfigurablePropertyResolver#setRequiredProperties//獲取當前環境對象,設置環境對象的屬性值getEnvironment().validateRequiredProperties();// 存儲監聽器if (this.earlyApplicationListeners == null) {this.earlyApplicationListeners = new LinkedHashSet<>(this.applicationListeners);}else {// Reset local application listeners to pre-refresh state.this.applicationListeners.clear();this.applicationListeners.addAll(this.earlyApplicationListeners);}// Allow for the collection of early ApplicationEvents,// to be published once the multicaster is available...this.earlyApplicationEvents = new LinkedHashSet<>();}

02.obtainFreshBeanFactory
在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/716609.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/716609.shtml
英文地址,請注明出處:http://en.pswp.cn/news/716609.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Redis常用指令,jedis與持久化

1.redis常用指令 第一個是key的常用指令&#xff0c;第二個是數據庫的常用指令 前面的那些指令都是針對某一個數據類型操作的&#xff0c;現在的都是對所有的操作的 1.key常用指令 key應該設計哪些操作 key是一個字符串&#xff0c;通過key獲取redis中保存的數據 對于key…

flink重溫筆記(九):Flink 高級 API 開發——flink 四大基石之WaterMark(Time為核心)

Flink學習筆記 前言&#xff1a;今天是學習 flink 的第 9 天啦&#xff01;學習了 flink 四大基石之 Time的應用—> Watermark&#xff08;水印&#xff0c;也稱水位線&#xff09;&#xff0c;主要是解決數據由于網絡延遲問題&#xff0c;出現數據亂序或者遲到數據現象&…

通過大語言模型理解運維故障:評估和總結

張圣林 南開大學軟件學院副教授、博士生導師 第六屆CCF國際AIOps挑戰賽程序委員會主席 在ATC、WWW、VLDB、KDD、SIGMETRICS等國際會議和JSAC、TC、TSC等國際期刊發表高水平論文50余篇。主持國家自然科學基金項目2項&#xff0c;橫向項目13項&#xff08;與華為、字節跳動、騰訊…

Sqli-labs靶場第20關詳解[Sqli-labs-less-20]自動化注入-SQLmap工具注入

Sqli-labs-Less-20 通過測試發現&#xff0c;在登錄界面沒有注入點&#xff0c;通過已知賬號密碼admin&#xff0c;admin進行登錄發現&#xff1a; 登錄后會有記錄 Cookie 值 設想如果在Cookie嘗試加上注入語句&#xff08;報錯注入&#xff09;&#xff0c;測試是否會執行…

C++STL之vector

vector 1. vector介紹 vector文檔vector其實就是一個順序表&#xff0c;它表示可變大小數組的序列容器。像數組一樣&#xff0c;可以使用下標[] 來訪問vector的元素&#xff0c;和數組一樣高效&#xff1b;甚至&#xff0c;它的大小是可以動態改變的&#xff0c;其大小由容器自…

printf() 函數支持變長參數列表

printf() 函數也支持變長參數列表&#xff0c;可以使用省略號 … 來表示&#xff0c;用于指定要輸出的多個值。在函數內部&#xff0c;可以使用 va_start() 和 va_end() 宏來訪問變長參數列表中的值。例如&#xff1a; #include <stdio.h> #include <stdarg.h>voi…

軟考55-上午題-【數據庫】-數據庫設計步驟1

一、數據庫設計的步驟 新奧爾良法&#xff0c;四個主要階段&#xff1a; 1、用戶需求分析&#xff1a;手機用戶需求&#xff0c;確定系統邊界&#xff1b; 2、概念設計&#xff08;概念結構設計&#xff09;&#xff1a;是抽象概念模型&#xff0c;較理想的是采用E-R方法。 …

深度學習:開啟你的AI探索之旅

在這個信息爆炸的時代,人工智能(AI)已經滲透到我們生活的方方面面,從智能語音助手到自動駕駛汽車,從智能推薦系統到醫療影像診斷,AI的身影無處不在。而深度學習,作為AI領域的一大核心技術,更是引領著這場科技革命的浪潮。那么,如何入門深度學習,踏上這趟充滿挑戰與機…

深入Gradle:初識構建自動化的魅力

在軟件開發的世界中&#xff0c;構建工具是不可或缺的一部分。它們幫助我們自動化編譯、測試和打包應用程序的過程&#xff0c;從而節省時間并減少錯誤。在眾多構建工具中&#xff0c;Gradle以其靈活性、可擴展性和卓越的性能而脫穎而出。本篇文章將帶你走進Gradle的世界&#…

代碼隨想錄算法訓練營第七天

● 自己看到題目的第一想法 第454題.四數相加II 方法&#xff1a; 方法一&#xff1a; 暴力法 思路&#xff1a; 注意&#xff1a; 代碼&#xff1a; class Solution { public:int fourSumCount(vector<int>& nums1, vector<int>& nums2, vector<i…

QT 網絡編程 8

1 基礎知識 udp tcp 2 UDP 框架 客戶端: QUdpSocket x; qint64 writeDatagram( const char *data, qint64 size, const QHostAddress &address, quint16 port );服務器: void Server::initSocket(){udpSocket new QUdpSocket(this);udpSocket->bind(QHostAddress…

macos jupyter notebook字體的修改

終端codemirror 記事本打開 搜索font-family 修改font-size保存即可

重學SpringBoot3-@ConditionalOnXxx條件注解

重學SpringBoot3-ConditionalOnXxx條件注解 引言常見的條件注解常見的條件注解示例擴展條件注解1. ConditionalOnJndi2. ConditionalOnJava3. ConditionalOnCloudPlatform4. ConditionalOnEnabledResourceChain5. 自定義條件注解 總結 引言 Spring Boot 提供了一組強大的條件注…

ERDAS監督分類與溫度反演教程

本期帶來監督分類教程&#xff0c;更多內容&#xff0c;歡迎關注小編的公眾號梧桐涼月哦&#xff01;&#xff01;&#xff01; 一、研究區自然、地理環境特征&#xff1a; 1、景德鎮市位于中國江西省東北部&#xff0c;地處贛江中游的贛北盆地&#xff0c;地形地貌以丘陵和低…

mitmproxy代理

文章目錄 mitmproxy1. 網絡代理2. 安裝3. Https請求3.1 啟動mitmproxy3.2 獲取證書3.3 配置代理3.4 運行測試 4. 請求4.1 讀取請求4.2 修改請求4.3 攔截請求 5. 響應5.1 讀取響應5.2 修改響應 6. 案例&#xff1a;共享賬號6.1 登錄bilibili獲取cookies6.2 在代理請求中設置cook…

ER-NeRF實時對話數字人模型訓練與部署

ER-NeRF是基于NeRF用于生成數字人的方法&#xff0c;可以達到實時生成的效果。 下載源碼 cd D:\Projects\ git clone https://github.com/Fictionarry/ER-NeRF cd D:\Projects\ER-NeRF 下載模型 準備面部解析模型 wget https://github.com/YudongGuo/AD-NeRF/blob/master/…

MyBatisPlus入門教程

MyBatisPlus MyBatis-Plus (opens new window)&#xff08;簡稱 MP&#xff09;是一個 MyBatis (opens new window) 的增強工具&#xff0c;在 MyBatis 的基礎上只做增強不做改變&#xff0c;為簡化開發、提高效率而生。 官網地址&#xff1a;https://baomidou.com/ 一、入門案…

sql注入之sqli-labs-less-1 錯誤注入

輸入?id1 得到登錄頁面&#xff1a; 通過order by 函數試探&#xff1a; 5的時候報錯 試探到3 的時候返回正確的值&#xff1a; 然后繼續注入&#xff1a;?id -1 union select 1,2,3 -- 查看回顯點&#xff1a; 開始查看數據庫內容&#xff1a;id-1 union select 1,databa…

OpenXR 超詳細的spec--API初始化介紹

3.API 初始化 3.2 Function Pointers XrResult xrGetInstanceProcAddr(XrInstance instance,const char* name,PFN_xrVoidFunction* function); instance: XrInstance類型&#…

open-spider開源爬蟲工具:抖音數據采集

在當今信息爆炸的時代&#xff0c;網絡爬蟲作為一種自動化的數據收集工具&#xff0c;其重要性不言而喻。它能夠幫助我們從互聯網上高效地提取和處理數據&#xff0c;為數據分析、市場研究、內容監控等領域提供支持。抖音作為一個全球性的短視頻平臺&#xff0c;擁有海量的用戶…