调用接口报错
Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Unexpected EOF read on the socket; nested exception is java.io.EOFException: Unexpected EOF read on the socket
解决方式
调用的接口处的
@RequestBody
改为@RequestBody(required = false)
即可
出现原因
原因是调用接口没有传Content-Type:application/json
测试
实测如果没有添加required = false
会导致调用接口直接报上面错误甚至服务的崩溃,加上required = false如果没传Content-Type:application/json
只会让接口无法接收到数据,也不会报错,服务不会崩溃