xml 配置项:

<bean id="propertyConfigurer" class="com.boc.icms.archive.util.ExPropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>xdb.properties</value>
<value>offline.properties</value>
</list>
</property>
</bean>

  

java代码:

public class ExPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {

    private final DefaultResourceLoader defaultResourceLoader;
private final String FILE_SEPERATOR = System.getProperty("file.separator");
private static Logger logger = Logger.getLogger(ExPropertyPlaceholderConfigurer.class); public ExPropertyPlaceholderConfigurer(){
defaultResourceLoader=new FileSystemResourceLoader();
} private Resource getResource(String fileName){
try{
String filePath = System.getProperty(PubConst.SERVER_CFG_DIR)+FILE_SEPERATOR+fileName;
return defaultResourceLoader.getResource(filePath);
}catch(Exception e){
logger.error("get["+fileName+"]Resource Exception",e);
return null;
}
} public void setLocation(String location){
super.setLocation(getResource(location));
} /**
* 同时加载多个properties
*@auther zhangcd
*@date 2017年5月8日
*@param locations
*/
public void setLocations(List<String> locations){
if(locations != null && !locations.isEmpty()){
int size = locations.size();
Resource[] res = new Resource[size];
for(int i = 0;i<size;i++){
res[i]= getResource(locations.get(i));
}
super.setLocations(res);
}
} }

xml 加载多个properties文件的更多相关文章

  1. 1. Spring基于xml加载和读取properties文件配置

    在src目录下,新建test.properties配置文件,内容如下 name=root password=123456 logArchiveCron=0/5 * * * * ? 一种是使用sprin ...

  2. java 加载并读取Properties 文件

    1 .系统自带的application.properties  (以下代码仅供参考,不能粘贴复制) 假设application.properties文件有下面两个值: come.test.name = ...

  3. maven 不同环境加载不同的properties 文件

    http://haohaoxuexi.iteye.com/blog/1900568 //参考文章 实际项目中pom配置如下 <profiles> <profile> <i ...

  4. 在maven pom.xml中加载不同的properties ,如localhost 和 dev master等jdbc.properties 中的链接不一样

    [参考]:maven pom.xml加载不同properties配置[转] 首先 看看效果: 点开我们项目中的Maven projects 后,会发现右侧 我们profile有个可勾选选项.默认勾选l ...

  5. spring 加载属性(properties)文件

    在开发的过程中,配置文件往往就是那些属性(properties)文件,比如使用properties文件配置数据库文件,又如database-config.properties 代码清单:databas ...

  6. web.xml加载过程

    web.xml加载过程:1 启动WEB项目的时候,容器(如:Tomcat)会读他的配置文件web.xml读两个节点  <listener></listener>和<con ...

  7. 实战android菜单项之XML加载菜单与动态菜单项[转]

    原文地址:http://blog.csdn.net/kaiwii/article/details/7767225 自定义android应用程序的菜单项首先要知道切入点.经过学习,知道主要是两个Acti ...

  8. JAVA Web.xml 加载顺序

    web.xml加载过程(步骤): 1.启动WEB项目的时候,容器(如:Tomcat)会去读它的配置文件web.xml.读两个节点: <listener></listener> ...

  9. Java web.xml加载顺序

     web.xml加载过程(步骤): 1.启动WEB项目的时候,容器(如:Tomcat)会去读它的配置文件web.xml.读两个节点:   <listener></listener&g ...

随机推荐

  1. 对网站视频资源的管控-禁止通过视频的url访问视频

    一般静态文件的下载是不经过PHP的,直接由web服务器发送到客户端.但有时候需要实现文件下载的权限控制等功能,这时候就需要经由PHP程序来做权限验证.简单粗暴的做法是,在PHP程序里边先验证权限,验证 ...

  2. 《android开发艺术探索》读书笔记(九)--四大组件

    接上篇<android开发艺术探索>读书笔记(八)--WindowManager No1: 四大组件除了BroadcastReceiver,其他三种组件都必须在AndroidManifes ...

  3. js处理时间戳显示的问题

    function getDate(tm){ ); var year = date.getFullYear(); var month = date.getMonth()+1; var day = dat ...

  4. win10安装mongodb及配置 和 mongodb的基本使用(node环境)

    mongodb安装 下载地址: https://www.mongodb.com/download-center 下载后,我们点击mongodb-win32-x86_64-2008plus-ssl-3. ...

  5. 微信企业号JS-SDK选择图片、上传图片

    因公司项目需要,要修改一个手机端上传图片的一个功能,原本的项目用的是input 的file控件上传的,虽然标注了可以多选,但是在实际运用当中只有iOS手机可以实现多选,Android手机并不支持多选, ...

  6. shell脚本——mysql

    很期待,学习shell脚本,减少重复工作 自动安装配置mysql脚本: #/bin/bash LOG_FILE=/home/hadoop1/log/installmysql.log function ...

  7. 笔记︱支持向量机SVM在金融风险欺诈中应用简述

    本笔记源于CDA-DSC课程,由常国珍老师主讲.该训练营第一期为风控主题,培训内容十分紧凑,非常好,推荐:CDA数据科学家训练营 欺诈一般不用什么深入的模型进行拟合,比较看重分析员对业务的了解,从异常 ...

  8. SystemVerilog语言简介(一)

    1. 接口(Interface) Verilog模块之间的连接是通过模块端口进行的.为了给组成设计的各个模块定义端口,我们必须对期望的硬件设计有一个详细的认识.不幸的是,在设计的早期,我们很难把握设计 ...

  9. Django学习-19-缓存

    由于Django是动态网站,所有每次请求均会去数据进行相应的操作,当程序访问量大时,耗时必然会更加明显,最简单解决方式是使用:缓存,缓存将一个某个views的返回值保存至内存或者memcache中,5 ...

  10. CF370 D Memory and Scores

    dp题 并运用了前缀和 我看题目提示中有fft 我想了下感觉复杂度不过关还是未解 #include<bits/stdc++.h> using namespace std; typedef ...