为了账号安全,请及时绑定邮箱和手机立即绑定

请教一下,为啥return CommonReturnType.create(itemVO)就会报下面这个错误?

WARN 2332 --- [nio-8090-exec-1] .m.m.a.ExceptionHandlerExceptionResolver :

Resolved [org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class com.miaoshaproject.controller.viewobject.ItemVO]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.miaoshaproject.controller.viewobject.ItemVO and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.miaoshaproject.response.CommonReturnType["data"])]

我调试了一下,发现

BeanUtils.copyProperties(itemModel, itemVO);

根本就没有把属性值copy给itemVO,但是我的itemModel和itemVO的字段完全一致,包括字段的类型。这是为什么

正在回答

8 回答

我也这个错误,哭了


0 回复 有任何疑惑可以回复我~

我也是这个错误555555

0 回复 有任何疑惑可以回复我~

我也是你这个错误哈哈

0 回复 有任何疑惑可以回复我~

翻译过来就是——spring报错说:兄弟,我没办法给你的ItemVO序列化啊,我不能get和set你的ItemVO里的私有变量。。。。spacer.gif 

1 回复 有任何疑惑可以回复我~
#1

斯基姆斯

我觉得奇怪的是,为啥视频里调试的时候没碰到我们这些坑呢。。。。。。
2019-01-23 回复 有任何疑惑可以回复我~
#2

dusty_z 提问者 回复 斯基姆斯

“特意”锻炼学生的debug能力
2019-01-25 回复 有任何疑惑可以回复我~

3点40看到你这条。。。关灯睡觉了。

1 回复 有任何疑惑可以回复我~

还是自己来终结吧。经过跟踪源码,发现是忘了给itemVO的属性赋予get/set方法。ps:建议各位不是夜猫子的还是不要半夜里写代码,是真容易出bug。。。

3 回复 有任何疑惑可以回复我~
#1

OCM

我还想实现序列化接口呢,原来是没有生成get/set方法。
2019-05-30 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

请教一下,为啥return CommonReturnType.create(itemVO)就会报下面这个错误?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信