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 ...
随机推荐
- PHP - curl实现采集
1.开启curl支持 由于php环境安装后默认是没有打开curl支持的,需修改php.ini文件,找到;extension=php_curl.dll,把前面的冒号去掉,重启服务即可: 2.使用curl ...
- 整理几个js上传多张图片的效果
一.普通的上传图片,张数不限制 <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"&g ...
- 关于druid的配置说明
<bean id="stat-filter" class="com.alibaba.druid.filter.stat.StatFilter"> & ...
- 【php】PHP环境整合
很久没装环境, 今天重新装了一次.遇到不少问题.记录下方便以后查看 修改apache的配置文件httpd.conf #apache 解析phpLoadFile "C:/phpeve/php5 ...
- php面向对象学习笔记01-面向对象介绍、构造函数、析构函数
偶尔翻看以前的笔记.就整理下.方便以后的查阅 类-成员属性 成员属性是从某个事务提取出来的, 可以是基本数据类型,也可以是复合数据类型(数组,对象) //创建一个类 class Cat{ pubic ...
- R语言︱画图
笔者寄语:不论画啥,你先plot准没错. plot 二维坐标绘图 dotchart 点图 barplot 条形图 hist 直方图 pie 饼图 points 添加点 lines 添加线 text 添 ...
- MySQL插入数据异常
MySQL插入数据异常 1.错误如下: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:Dupli ...
- freemarker写select组件报错总结(一)
1.具体错误如下 六月 25, 2014 11:26:29 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template pr ...
- 表格布局----基于bootstrap样式 布局
在实际开发中,我们通过菜鸟教程复制的表格往往不能满足我们的开发需求,样式很难看,而且不能自适应,尤其是需要到处Excel的样式,感觉非常糟糕,这次我就写了一个表单,不足之处,希望大神们多多指教: 代码 ...
- javaWeb之自动发送邮件生日祝福(ServletContextListener监听)
在看完本随笔仍然不理解的可以看 javaWeb邮箱发送 :里面有具体的邮箱服务器配置 企业在员工生日当天发送邮箱生日祝福: 一般是用监听器完成: 而合适的监听是ServletContextLis ...