xml 加载多个properties文件
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. Spring基于xml加载和读取properties文件配置
在src目录下,新建test.properties配置文件,内容如下 name=root password=123456 logArchiveCron=0/5 * * * * ? 一种是使用sprin ...
- java 加载并读取Properties 文件
1 .系统自带的application.properties (以下代码仅供参考,不能粘贴复制) 假设application.properties文件有下面两个值: come.test.name = ...
- maven 不同环境加载不同的properties 文件
http://haohaoxuexi.iteye.com/blog/1900568 //参考文章 实际项目中pom配置如下 <profiles> <profile> <i ...
- 在maven pom.xml中加载不同的properties ,如localhost 和 dev master等jdbc.properties 中的链接不一样
[参考]:maven pom.xml加载不同properties配置[转] 首先 看看效果: 点开我们项目中的Maven projects 后,会发现右侧 我们profile有个可勾选选项.默认勾选l ...
- spring 加载属性(properties)文件
在开发的过程中,配置文件往往就是那些属性(properties)文件,比如使用properties文件配置数据库文件,又如database-config.properties 代码清单:databas ...
- web.xml加载过程
web.xml加载过程:1 启动WEB项目的时候,容器(如:Tomcat)会读他的配置文件web.xml读两个节点 <listener></listener>和<con ...
- 实战android菜单项之XML加载菜单与动态菜单项[转]
原文地址:http://blog.csdn.net/kaiwii/article/details/7767225 自定义android应用程序的菜单项首先要知道切入点.经过学习,知道主要是两个Acti ...
- JAVA Web.xml 加载顺序
web.xml加载过程(步骤): 1.启动WEB项目的时候,容器(如:Tomcat)会去读它的配置文件web.xml.读两个节点: <listener></listener> ...
- Java web.xml加载顺序
web.xml加载过程(步骤): 1.启动WEB项目的时候,容器(如:Tomcat)会去读它的配置文件web.xml.读两个节点: <listener></listener&g ...
随机推荐
- Mysql(六):数据备份、pymysql模块
一 IDE工具介绍 生产环境还是推荐使用mysql命令行,但为了方便我们测试,可以使用IDE工具 下载链接:https://pan.baidu.com/s/1bpo5mqj 掌握: #1. 测试+链接 ...
- nyoj1246 逃离妖洞 BFS
逃离妖洞 描述 唐僧不小心又掉入妖怪的迷宫了.这个迷宫有n行m列,共n*m个方格.有的方格是空的,唐僧可以站在上面,有些是有障碍物的不能站.每次唐僧可以移动到相邻的8个空方格上.但是有些情况不 ...
- caffe错误
一些caffe错误 训练时很快梯度爆炸,loss猛增至nan 如果找不到数据上的原因的话,可以怀疑caffe框架有问题,换用其它版本试试.比如我遇到的问题是在训练时使用了Accuracy层,而该层的实 ...
- Android开发之组件
Android应用程序由组件组成,组件是可以解决被调用的基本功能模块.Android系统利用组件实现程序内部或程序间的模块调用,以解决代码复用问题,这是Android系统非常重要的特性.在程序设计时, ...
- 修改Cosbench源码 支持s3的 http range request 测试场景
在视频点播的业务应用场景中,用户使用了ffmpeg工具做视频实时转码用. 而ffmpeg使用range 请求.而Cosbench不支持这种测试场景,所以需要修改源码支持这种测试场景. HTTP 协议介 ...
- 安装Apache提示APR not found的解决办法
不知道为什么在安装apache2.2.22版本的时候没有任何问题,直接使用命令 ./configure --prefix=/home/www/www_test/software/apache-2.2. ...
- 错误号:1364 错误信息:Field 'platId' doesn't have a default value
1. 错误描述 错误号:1364 错误信息:Field 'platId' doesn't have a default value insert into `use`.`t_platform_scal ...
- java.lang.IllegalStateException: Failed to load ApplicationContext
1.错误描述 七月 13, 2014 6:34:41 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBean ...
- CodeM资格赛 Round A 最长树链
按照题解的做法,对于每一个质约数分别进行讨论最长链就行 对于每一个数的质约数可是比logn还要小的 比赛的时候没人写,我也没看 = =,可惜了,不过我当时对于复杂度的把握也不大啊 #include & ...
- pycharm short-cut
Ctrl + the left mouse button Ctrl + Alt + Left/Right if invalid, system setting