解决:Could not write JSON: No serializer found for class *** and no properties错误


场景:使用RestController或者Controller注解将查询的实体转换成json字符串时报错。

原因:需要转换的对应实体类的属性缺少:getter和setter方法,导致将实体类转换的json格式类无法读取对应的属性从而报错。

解决方法:在需要转换的实体类中给属性加上getter和setter方法(或者使用:lombok插件给实体类加上getter和setter注解)。

错误信息为:Request processing failed;nested exception is java.lang.IllegalArgumentException;No converter found for return value of type...的原因同样是实体类缺少getter和setter方法,解决方法如上。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM