Spring REST文档-由于输入结束,没有要映射的内容

Spring REST文档-由于输入结束,没有要映射的内容,rest,spring-boot,spring-mvc,mockmvc,spring-restdocs,Rest,Spring Boot,Spring Mvc,Mockmvc,Spring Restdocs,我有一个springBoot 2.1.9.RELEASE应用程序,它使用SpringREST文档 我的TestController中有这个方法 @Test public void createOK() throws Exception { String content = ResourceUtils.getResourceFileAsString ("/new_hostel.json"); mockMvc.perform(post("/hostel"

我有一个springBoot 2.1.9.RELEASE应用程序,它使用SpringREST文档

我的TestController中有这个方法

@Test
    public void createOK() throws Exception {


        String content = ResourceUtils.getResourceFileAsString ("/new_hostel.json");

        mockMvc.perform(post("/hostel")
                .content(content)
                .contentType(APPLICATION_JSON))
                .andExpect(status().isOk())
                .andDo(document("create-hostel",
                        preprocessRequest(prettyPrint()),
                        preprocessResponse(prettyPrint()),
                        links(halLinks(),
                                linkWithRel("ld:GetHostel").
                                        description("Get Hostel"),
                                linkWithRel("curies").
                                        description("Documentation")),
                        requestFields(
                                fieldWithPath("description").description("The description"),
                                fieldWithPath("name").description("The name"),                              
                                fieldWithPath("id").description("The id")
                        )
                ));
    }
但当我运行它时,我有一个错误:

org.springframework.restdocs.snippet.ModelCreationException: com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (byte[])""; line: 1, column: 0]

    at org.springframework.restdocs.hypermedia.LinksSnippet.createModel(LinksSnippet.java:127)
    at org.springframework.restdocs.snippet.TemplatedSnippet.document(TemplatedSnippet.java:81)
    at org.springframework.restdocs.generate.RestDocumentationGenerator.handle(RestDocumentationGenerator.java:201)
    at org.springframework.restdocs.mockmvc.RestDocumentationResultHandler.handle(RestDocumentationResultHandler.java:55)
    at org.springframework.test.web.servlet.MockMvc$1.andDo(MockMvc.java:200)
    at com.bendiciones.buenas.noches.HostelControllerIT.createOK(HostelControllerIT.java:88)

链接片段记录响应中的超媒体链接。根据错误判断,控制器的响应为空,因此没有指向文档的链接。您应该更新测试以删除对
POST
请求的响应中链接的文档,或者更新处理它的控制器方法以返回包含一些链接的正文。

链接片段记录响应中的链接。从错误判断,响应似乎是空的。向/hotel发帖请求返回了什么?@AndyWilkinson,确实是这个问题,请转换为回答