/**
* 获取配置文件中指定属性的值
* @param key 配置文件中的属性名称
* @return 返回属性的值
*/
protected String getProperty(String key)
{
String[] configValue = getProperties(key);
return configValue[0];
}
/**
* 获取配置文件中所有属性的相应值
* @return 返回属性的名称及值的数组
*/
protected String[] getProperties(String key)
{
String[] configValue = null;
try{
CompositeConfiguration config = new CompositeConfiguration();
config.addConfiguration(new XMLConfiguration("aaa.xml"));
config.addConfiguration(new XMLConfiguration("bbb.xml"));
configValue = config.getStringArray(key);
}catch(ConfigurationException e)
{
log.error("读配置文件:",e);
e.printStackTrace();
}
return configValue;
}
common-configuration读取xml,properties文件(二)
最新推荐文章于 2023-05-25 20:13:29 发布