我遇到了 Spring AutoRest Docs 的问题。似乎源于这段代码
.alwaysDo<DefaultMockMvcBuilder>(JacksonResultHandlers.prepareJackson(objectMapper))
完整配置:
mockMvc = MockMvcBuilders
.webAppContextSetup(webApplicationContext)
.alwaysDo<DefaultMockMvcBuilder>(JacksonResultHandlers.prepareJackson(objectMapper))
.alwaysDo<DefaultMockMvcBuilder>(document("{class-name}/{method-name}",
Preprocessors.preprocessRequest(Preprocessors.prettyPrint()),
Preprocessors.preprocessResponse(Preprocessors.prettyPrint())))
.apply<DefaultMockMvcBuilder>(documentationConfiguration(this.restDocumentation)
.uris()
.withScheme("https")
.withHost("localhost")
.and().snippets()
.withDefaults(CliDocumentation.curlRequest(),
HttpDocumentation.httpRequest(),
HttpDocumentation.httpResponse(),
AutoDocumentation.requestFields()
.failOnUndocumentedFields(true),
AutoDocumentation.responseFields()
.failOnUndocumentedFields(true),
AutoDocumentation.pathParameters(),
AutoDocumentation.requestParameters(),
AutoDocumentation.description(),
AutoDocumentation.methodAndPath(),
AutoDocumentation.section(),
AutoDocumentation.links()))
.build()
我已经对杰克逊进行了一些定制,而 autorest 似乎不喜欢这样。当我输入 my 时objectMapper
,我收到以下警告:
No Javadoc found for class java.lang.Object
No Javadoc found for class java.io.Serializable
No description found for constraint com.domain.CLASS: Can't find resource for bundle java.util.PropertyResourceBundle, key com.domain.CLASS.description
我尝试注入其他方法来获取对象映射器,包括
MappingJackson2HttpMessageConverter
ObjectMapperResolver
我也尝试过启动一个新的 Spring Boot 应用程序并且没有遇到任何错误。但是,如果prepareJackson
删除没有更多警告,则自动生成的文档中没有数据。
我已经在这个问题上停留了很长一段时间,不知道如何解决它。任何指导将不胜感激。