1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > SpringBoot 封装返回类报错:No converter found for return value of type

SpringBoot 封装返回类报错:No converter found for return value of type

时间:2024-05-21 12:09:59

相关推荐

SpringBoot 封装返回类报错:No converter found for return value of type

封装完毕Result返回类,使用PostMan测试时报错

{"timestamp": "-06-03T10:38:03.144+0000","status": 500,"error": "Internal Server Error","message": "No converter found for return value of type: class com.jia.wxbike.utils.Result","path": "/bike/addBike"}

IDEA控制台报错如下:

-06-03 18:37:00.126 WARN 25904 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class com.jia.wxbike.utils.Result]-06-03 18:38:03.142 WARN 25904 --- [nio-8080-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class com.jia.wxbike.utils.Result]

解决方法:查询得知因为Result类缺少Get,Set方法,使用lombok的@Data注解,或者手动添加Get,Set方法即可解决。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。