我有我的 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
}
我需要使用另一个外部属性文件,与中所示的不同@PropertySource
in Application
班级。因此,我添加了@TestPropertySource
,但似乎这个注释并没有覆盖@PropertySource
.
我能做些什么?
提前致谢。
这样使用它:
@TestPropertySource(locations = "classpath:test.properties")
并将测试属性文件放入src/test/resources
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)