我有三个属性文件:具有重叠位置的多个属性占位符不起作用?
file1.properties包含:
propA=1
file2.properties包含:
propA=2 propB=2
file3.properties包含:
propA=3 propB=3 propC=3
和两个应用上下文:
applicationContext1.xml包含:
<context:property-placeholder location="classpath:file1.properties,classpath:file2.properties" ignore-resource-not-found="true" ignore-unresolvable="true" system-properties-mode="OVERRIDE"/>
applicationContext2.xml包含:
<context:property-placeholder location="classpath:file2.properties,classpath:file3.properties" ignore-resource-not-found="true" ignore-unresolvable="true" system-properties-mode="OVERRIDE"/>
而且加载两种情况下,插入一个测试所有属性。 MyTest.java:
@Value("${propA}")
private String propA;
@Value("${propB}")
private String propB;
@Value("${propC}")
private String propC;
,我得到以下值:
propA=2
propB=2
propC=3
为什么 'propA' 和 'PROPB' 不是从file3.properties取?
为什么要这样。一旦它被替换,它被替换。如果第一个占位符已经完成了工作,那么就没有什么可以替代的了。 – 2014-11-25 09:28:15