首页 > 移动平台 > 详细

【Spring源码这样读】-细扒ApplicationContext之setConfigLocations(configLocations)

时间:2021-04-20 21:03:35      阅读:29      评论:0      收藏:0      [点我收藏+]

细扒之继续讲容器初始化流程,上篇讲了super(parent),本章初始化的下一步setConfigLocations(configLocations);大佬请略过

setConfigLocations(configLocations)对应源码

public void setConfigLocations(@Nullable String... locations) {
	if (locations != null) {
		Assert.noNullElements(locations, "Config locations must not be null");
		this.configLocations = new String[locations.length];
		for (int i = 0; i < locations.length; i++) {
			this.configLocations[i] = resolvePath(locations[i]).trim();
		}
	}
	else {
		this.configLocations = null;
	}
}

protected String resolvePath(String path) {
	return getEnvironment().resolveRequiredPlaceholders(path);
}

源码的注释其实写得比较明了,一句话概括了:设置此应用程序上下文的配置位置,如果未设置,则实现可酌情使用默认值。

【Spring源码这样读】-细扒ApplicationContext之setConfigLocations(configLocations)

原文:https://www.cnblogs.com/xlecho/p/14682311.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!