【发布时间】:2016-08-05 12:36:16
【问题描述】:
我有我的 Spring Boot 主类:
@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。
我能做什么?
提前致谢。
【问题讨论】:
标签: java spring spring-boot spring-test