开发者社区> 问答> 正文

使用mybatis的collection属性报错?报错

"exception": "org.springframework.http.converter.HttpMessageNotWritableException",
    "message": "Could not write content: No serializer found for class org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory$EnhancedResultObjectProxyImpl and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.chinamcloud.cms.api.dto.ReturnDto[\"returnData\"]->java.util.ArrayList[0]->com.chinamcloud.cms.repository.vo.CommentListVO_$$_jvst7cb_0[\"handler\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory$EnhancedResultObjectProxyImpl and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.chinamcloud.cms.api.dto.ReturnDto[\"returnData\"]->java.util.ArrayList[0]->com.chinamcloud.cms.repository.vo.CommentListVO_$$_jvst7cb_0[\"handler\"])",

展开
收起
爱吃鱼的程序员 2020-06-08 16:48:39 741 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    http://moguichun.com/2016/04/18/SpringMVC-Mybatis%E6%95%B4%E5%90%88%E8%BF%94%E5%9B%9EJSON%E6%95%B0%E6%8D%AE%E5%87%BA%E7%8E%B0%E7%9A%84Could-not-write-content-No-serializer-found-for-class-%E9%94%99%E8%AF%AF%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95/

    嗯,用VO对输出可以的实体类有一个属性是其它实体类的类型,mybatis默认使用了延迟加载,导致在处理这个类的时候某些属性不能被序列化,因此造成了上述原因。

    https://github.com/mybatis/mybatis-3/issues/570

    2020-06-08 16:48:50
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Java Spring Boot开发实战系列课程【第6讲】:Spring Boot 2.0实战MyBatis与优化(Java面试题) 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载