返回介绍

6.1 设置配置路径

发布于 2025-04-22 22:09:11 字数 620 浏览 0 评论 0 收藏

在 ClassPathXmlApplicationContext 中支持多个配置文件以数组方式同时传入:

public void setConfigLocations(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;

 }

}

此函数主要用于解析给定的路径数组,当然,如果数组中包含特殊符号,如${var},那么在 resolvePath 中会搜寻匹配的系统变量并替换。

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。