假设我有以下两个配置文件:
文件一:
key1 = ${common.key1}
key2 = ${common.key2}
文件2:
common.key1 = value1
common.key2 = value2
我有以下代码:
import org.apache.commons.configuration.PropertiesConfiguration;
...
PropertiesConfiguration newConfig = new PropertiesConfiguration();
File configFile1 = new File("...paht to file 1");
File configFile2 = new File("...path to file 2");
newConfig.setDelimiterParsingDisabled(true);
newConfig.load(configFile2);
newConfig.load(configFile1);
Iterator<String> props = newConfig.getKeys();
while (props.hasNext()) {
String propName = props.next();
String propValue = newConfig.getProperty(propName).toString();
System.out.println(propName + " = " + propValue);
}
我有以下输出:
common.key1 = value1
common.key2 = value2
key1 = ${common.key1}
key2 = ${common.key2}
为什么占位符没有解析?
喵喔喔
12345678_0001
相关分类