我有这个 Spring 休息 Controller :

@RestController
@RequestMapping("/communications")
class CommunicationController(private val service: CommunicationService) {

    @ApiOperation(
        produces = APPLICATION_JSON_VALUE,
        consumes = APPLICATION_JSON_VALUE
    )
    @GetMapping(
        consumes = [APPLICATION_JSON_VALUE],
        produces = [APPLICATION_JSON_VALUE]
    )
    fun findAll(
        criterias: CommunicationCriterias,
        page: Pageable
    ): List<CommunicationDTO> = service.findCommunications(criterias, page)

}

当我通过swagger-ui(springfox)接口(interface)测试此端点时,出现了415: content type invalid错误。似乎 header 中未设置content-type: application/json

有什么不见了 ?

最佳答案

HTTP GET请求中没有任何消耗。我认为您应该从consumes@GetMapping中删除@ApiOperation

09-04 22:32