最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Spring中的ClassPathXmlApplicationContext源碼詳解

 更新時(shí)間:2023年12月01日 10:01:38   作者:軍偉@  
這篇文章主要介紹了Spring中的ClassPathXmlApplicationContext源碼詳解,ApplicationContext的主要實(shí)現(xiàn)類是ClassPathXmlApplicationContext和FileSystemXmlApplicationContext,前者默認(rèn)從類路徑加載配置文件,后者默認(rèn)從文件系統(tǒng)中裝載配置文件,需要的朋友可以參考下

ClassPathXmlApplicationContext源碼

ApplicationContext應(yīng)用上下文體系如下:

在實(shí)現(xiàn)類ClassPathXmlApplicationContext中其實(shí)并沒有多少重要的操作,主要是在構(gòu)造函數(shù)中配置Spring配置文件的路徑:

public class DaoOperationMain {
	public static void main(String[] args) {
		ApplicationContext appCtx = new ClassPathXmlApplicationContext("applicationContext.xml");
	}
}

具體的applicationContext.xml解析相關(guān)的操作都在父類refresh中進(jìn)行操作。

ClassPathXmlApplicationContext的源碼如下:

/**
 * 并沒有太多具體的操作,主要是初始化構(gòu)造函數(shù),主要的操作都在父類中
 */
public class ClassPathXmlApplicationContext extends AbstractXmlApplicationContext {
	private Resource[] configResources;
	public ClassPathXmlApplicationContext() {
	}
	public ClassPathXmlApplicationContext(ApplicationContext parent) {
		super(parent);
	}
	public ClassPathXmlApplicationContext(String configLocation) throws BeansException {
		this(new String[] {configLocation}, true, null);
	}
	public ClassPathXmlApplicationContext(String... configLocations) throws BeansException {
		this(configLocations, true, null);
	}
	public ClassPathXmlApplicationContext(String[] configLocations, ApplicationContext parent) throws BeansException {
		this(configLocations, true, parent);
	}
	public ClassPathXmlApplicationContext(String[] configLocations, boolean refresh) throws BeansException {
		this(configLocations, refresh, null);
	}
	public ClassPathXmlApplicationContext(String[] configLocations, boolean refresh, ApplicationContext parent)
			throws BeansException {
		super(parent);
		//設(shè)置spring的配置文件
		setConfigLocations(configLocations);
		if (refresh) {
			//調(diào)用父類的refresh函數(shù),進(jìn)行一系列初始化
			refresh();
		}
	}
	public ClassPathXmlApplicationContext(String path, Class<?> clazz) throws BeansException {
		this(new String[] {path}, clazz);
	}
	public ClassPathXmlApplicationContext(String[] paths, Class<?> clazz) throws BeansException {
		this(paths, clazz, null);
	}
	public ClassPathXmlApplicationContext(String[] paths, Class<?> clazz, ApplicationContext parent)
			throws BeansException {
		super(parent);
		Assert.notNull(paths, "Path array must not be null");
		Assert.notNull(clazz, "Class argument must not be null");
		this.configResources = new Resource[paths.length];
		for (int i = 0; i < paths.length; i++) {
			this.configResources[i] = new ClassPathResource(paths[i], clazz);
		}
		//調(diào)用父類的refresh函數(shù),進(jìn)行一系列初始化
		refresh();
	}
	@Override
	protected Resource[] getConfigResources() {
		return this.configResources;
	}
}

到此這篇關(guān)于Spring中的ClassPathXmlApplicationContext源碼詳解的文章就介紹到這了,更多相關(guān)ClassPathXmlApplicationContext源碼內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • java 讀取本地文件實(shí)例詳解

    java 讀取本地文件實(shí)例詳解

    這篇文章主要介紹了java 讀取本地文件實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-05-05
  • Java中的logback標(biāo)記日志過濾器MarkerFilter詳解

    Java中的logback標(biāo)記日志過濾器MarkerFilter詳解

    這篇文章主要介紹了Java中的logback標(biāo)記日志過濾器MarkerFilter詳解,在logback-classic中存在一個(gè)全局過濾器TurboFilter,TurboFilter是與LoggerContext綁定,會(huì)在會(huì)在其它過濾器之前執(zhí)行,需要的朋友可以參考下
    2023-11-11
  • Java中==與equals的區(qū)別小結(jié)

    Java中==與equals的區(qū)別小結(jié)

    這篇文章主要介紹了Java中==與equals的區(qū)別小結(jié),本文總結(jié)結(jié)論:== 與 equals()比較的內(nèi)容是不同的,equals()方式是String類中的方法,它用于比較兩個(gè)對(duì)象引用所指的內(nèi)容是否相等,而 == 比較的是兩個(gè)對(duì)象引用的地址是否相等,需要的朋友可以參考下
    2015-06-06
  • Java使用鎖解決銀行取錢問題實(shí)例分析

    Java使用鎖解決銀行取錢問題實(shí)例分析

    這篇文章主要介紹了Java使用鎖解決銀行取錢問題,結(jié)合實(shí)例形式分析了java線程同步與鎖機(jī)制相關(guān)原理及操作注意事項(xiàng),需要的朋友可以參考下
    2019-08-08
  • 在IntelliJ IDEA中多線程并發(fā)代碼的調(diào)試方法詳解

    在IntelliJ IDEA中多線程并發(fā)代碼的調(diào)試方法詳解

    這篇文章主要介紹了在IntelliJ IDEA中多線程并發(fā)代碼的調(diào)試方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-08-08
  • JVM的常用命令匯總

    JVM的常用命令匯總

    監(jiān)測(cè)java應(yīng)用,最方便的就是直接使用jdk提供的現(xiàn)成工具,在jdk的安裝的bin目錄下,已經(jīng)提供了多種命令行監(jiān)測(cè)工具。本文為大家總結(jié)了幾個(gè)JVM的常用命令,需要的可以參考一下
    2022-10-10
  • SpringBoot集成nacos動(dòng)態(tài)刷新數(shù)據(jù)源的實(shí)現(xiàn)示例

    SpringBoot集成nacos動(dòng)態(tài)刷新數(shù)據(jù)源的實(shí)現(xiàn)示例

    這篇文章主要介紹了SpringBoot集成nacos動(dòng)態(tài)刷新數(shù)據(jù)源的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • Spring Cloud Gateway詳細(xì)使用最佳實(shí)踐

    Spring Cloud Gateway詳細(xì)使用最佳實(shí)踐

    Spring Cloud Gateway 是 Spring Cloud 生態(tài)系統(tǒng)中的現(xiàn)代化 API 網(wǎng)關(guān)組件,用于構(gòu)建微服務(wù)架構(gòu)中的統(tǒng)一入口網(wǎng)關(guān),本文介紹Spring Cloud Gateway詳細(xì)使用最佳實(shí)踐,感興趣的朋友一起看看吧
    2025-11-11
  • spring的jdbctemplate的crud的基類dao

    spring的jdbctemplate的crud的基類dao

    本文主要介紹了使用spring的jdbctemplate進(jìn)行增刪改查的基類Dao的簡單寫法,需要的朋友可以參考下
    2014-02-02
  • springboot使用redisTemplate操作lua腳本

    springboot使用redisTemplate操作lua腳本

    本文主要介紹了springboot使用redisTemplate操作lua腳本,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08

最新評(píng)論

姜堰市| 和田市| 苏尼特右旗| 美姑县| 西畴县| 仲巴县| 绿春县| 田东县| 左云县| 扎赉特旗| 定日县| 兴城市| 萝北县| 屏南县| 吉安县| 沂源县| 西峡县| 巴彦县| 东乌珠穆沁旗| 毕节市| 聊城市| 北安市| 西林县| 庐江县| 通州区| 武汉市| 万全县| 隆德县| 邓州市| 太白县| 安徽省| 崇信县| 阜南县| 九江市| 澄江县| 武乡县| 巢湖市| 樟树市| 苍南县| 壤塘县| 泾源县|