项目整合登录验证功能时遇到如下错误:

org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing

错误原因:

误把@GetMapping与@RequestBody放在一起使用

@GetMapping("login")
public R loginUser(@RequestBody UcenterMember member){
}

解决方式:

@GetMapping换成@PostMapping

@PostMapping("login")
public R loginUser(@RequestBody UcenterMember member){
}

stackoverflow上的一个类似问题:

https://stackoverflow.com/questions/42256358/spring-getmapping-with-requestparam-and-requestbody-fails-with-httpmessagenot

另附GET与POST的区别:

https://blog.fundebug.com/2019/02/22/compare-http-method-get-and-post/