是否可以加载这样的测试属性?@TestPropertySource("${test.config:'classpath:application.test.properties'}")关键是检查test.config参数(可能有类似的东西文件:c:/test.properties),如果未设置该值,则将从ClassPath中获取默认属性。我能够使用参数加载classpath的属性。我无法结合classpath和文件解决了:@PropertySource(value={"classpath:application.test.properties","${test.config}"},ignoreR
我有一个SpringBoot项目,效果很好。我现在想为我的应用程序编写测试,但我遇到了一些配置问题。Springboot为我创建了一个名为ApplicationTests的测试类。它真的很简单,看起来像这样:@RunWith(SpringRunner.class)@SpringBootTestpublicclassDuurzaamApplicationTests{@TestpublicvoidcontextLoads(){}}现在当我开始测试时,我得到了这个错误:java.lang.IllegalArgumentException:Couldnotresolveplaceholder'
我有一个SpringBoot项目,效果很好。我现在想为我的应用程序编写测试,但我遇到了一些配置问题。Springboot为我创建了一个名为ApplicationTests的测试类。它真的很简单,看起来像这样:@RunWith(SpringRunner.class)@SpringBootTestpublicclassDuurzaamApplicationTests{@TestpublicvoidcontextLoads(){}}现在当我开始测试时,我得到了这个错误:java.lang.IllegalArgumentException:Couldnotresolveplaceholder'
似乎我在Spring4.1.17中使用SpringBoot1.2.6.RELEASE所做的任何事情都不起作用。我只想访问应用程序属性并在必要时用测试覆盖它们(不使用黑客手动注入(inject)PropertySource)这不起作用..@TestPropertySource(properties={"elastic.index=test_index"})这个也不行..@TestPropertySource(locations="/classpath:document.properties")也不是这个..@PropertySource("classpath:/document.prop