定義されたプロパティを読み取るテストクラスを作成しました
@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.プロパティ
test.one=testone
test.two=test
テストの実行中、出力は
テストトーン,DEFAULT
プロパティから test.two を取得していません。
デフォルト値を指定していない場合
@Value("${test.two}")
private String test2;
出力は testone,test
誰でも助けることができますか?