1. 启动类
2. 测试类
@RunWith(SpringRunner.class) @SpringBootTest(classes = { ReportSplTestApp.class }) @AutoConfigureMockMvc @Test
模拟发送请求
@Autowired
MockMvc
String j = "{}"; MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post("/list/get"); request.content(j); MvcResult r = mockMvc.perform(request).andReturn(); String s = r.getResponse().getContentAsString(); System.out.println(s);