Spring Boot - Test for controller fails with 404 code

后端 未结 8 1188
一个人的身影
一个人的身影 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:35

    In my case it was about a missing starting slash /

    I've appended / to both RequestMapping value and MockHttpServletRequestBuilder post urlTemplate parameters as first character.

提交回复
热议问题