我正在尝试测试我的Spring配置。下面是我的config类
@Configuration
@PropertySource("/etc/my.properties")
@ComponentScan("my.package")
public class SpringConfig {
@Bean
.....
}
当我试着通过我的测试来测试它时
@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource(locations = "classpath:test.properties")
@ContextConfiguration(classes = {SpringConfigIntTest.class, SpringConfig.class})
public class SpringConfigIntTest {
.......
}
我一直收到失败消息,说/etc/my.properties找不到。但我认为我已经用test.properties覆盖了它,我一直在谷歌上搜索,没有看到其他人有不同的做法。
我使用了spring-context、spring-beans、spring-core 4.2.2和spring-test 4.2.4。有没有人能帮帮我?深深地感谢它
发布于 2016-11-15 06:23:15
如果资源不存在,则可以将属性源设置为不失败:
@PropertySource(value = "/etc/my.properties", ignoreResourceNotFound = true)
https://stackoverflow.com/questions/40534724
复制相似问题