我有我的春天啓動的主類:與@TestPropertySource覆蓋@PropertySource在春季啓動
@SpringBootApplication
@PropertySource("file:/my/file/properties")
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
//main method
}
我(使用@PropertySource
)讀取來自外部文件的屬性。現在,我有一個集成測試:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes= Application.class)
@WebIntegrationTest
@TestPropertySource("file:/my/test/file/properties") // <---
public class MyTest {
//some tests
}
我需要使用另一個外部屬性文件,從Application
類@PropertySource
指定的不同。出於這個原因,我添加了@TestPropertySource
,但似乎這個註釋並不是覆蓋@PropertySource
。
我該怎麼辦?
在此先感謝。
謝謝。有用。 –