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

前端 未结 10 624
野趣味
野趣味 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:45

    This works

    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.test.context.junit4.SpringRunner;
    
    @RunWith(SpringRunner.class)
    @SpringBootTest
    public class ApplicationTest {
    
        @Test
        public void contextLoads() {
        }
    
    }
    

提交回复
热议问题