I wrote a test class to read properties defined
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:config/TestOne.xml","classpath*:config/TestTwo.xml"
})
public class PropertyTest {
@Value("${test.one:DEFAULT}")
private String test;
@Value("${test.two:DEFAULT}")
private String test2;
@Test
public void TestProperty(){
System.out.println(test + "," + test2);
}
}
TestOne.xml
<context:property-placeholder
location="classpath*:/config/testone.properties"
ignore-unresolvable="true" order="1" />
TestTwo.xml
<context:property-placeholder
location="classpath*:/config/testtwo.properties"
ignore-unresolvable="true" order="2" />
testone.properties
test.one=testone
testtwo.properties
test.one=testone
test.two=test
While running the Test, output is
testone,DEFAULT
it is not fetching test.two from property.
If I am not specifying the default value
@Value("${test.two}")
private String test2;
Output is testone,test
Can anybody help?