Spring Boot - Test for controller fails with 404 code

后端 未结 8 1183
一个人的身影
一个人的身影 2021-01-04 18:17

I want to write a test for controller. Here is test snippet:

@RunWith(SpringRunner.class)
@WebMvcTest(WeatherStationController.class)
@ContextConfiguration(c         


        
8条回答
  •  情歌与酒
    2021-01-04 18:57

    I import external configuration class by @ContextConfiguration(classes = MyConfig.class)

    When I changed in MyConfig annotation @Configuration into @TestConfiguration it started to work properly.

提交回复
热议问题