Spring Boot properties in 'application.yml' not loading from JUnit Test

前端 未结 10 506
野趣味
野趣味 2021-01-31 13:59

What am I doing wrong? I\'m using this little standalone App which runs and finds my src/main/resources/config/application.yml. The same configuration doesn\'t work

10条回答
  •  失恋的感觉
    2021-01-31 14:46

    extending Liam's answer

    you can add spring.config.additional-location=classpath:application-overrides.yaml property so config from default location will be merged with the additional config provided:

    @RunWith(SpringRunner.class)
    @SpringBootTest
    @TestPropertySource(properties = {
      "spring.config.additional-location=classpath:testcases/test-case-properties.yaml",
    })
    public class SpecificTestCaseIntegrationTest {
    

提交回复
热议问题