Jackson:Cannot construct instance of **** (although at least one Creator exists):
Jackson:nested exception is java.lang.IllegalArgumentException: Cannot construct instance of **** (although at least one Creator exists):
要进行 json 转换的对象:
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;/*** 获取 DOM 信息的信息传递对象** @author : LiuXianghai on 2021/1/20* @Created : 2021/01/20 - 15:42* @Project : GetDataService*/
@Data
public class ParseDomMessage {@JsonCreatorpublic ParseDomMessage(@JsonProperty("message") String message,@JsonProperty("startFlag") Boolean isStartParse,@JsonProperty("finishedFlag") Boolean isParseEnd,@JsonProperty("count") Long count) {this.isParseEnd = isParseEnd;this.isStartParse = isStartParse;this.message = message;this.count = count;}@JsonCreatorpublic ParseDomMessage(){}// 传递的信息内容@JsonProperty("message")private String message;// 是否开始获取对应 DOM@JsonProperty("startFlag")private Boolean isStartParse;// 是否已经获取了对应的 DOM@JsonProperty("finishedFlag")private Boolean isParseEnd;/*计数标记, 每次发送的消息可能会被重新接受,因此这个属性的作用就是每次增加技术来避免可能会重复接受到同一消息的问题*/@JsonProperty("count")private Long count;
}
待转换的 json数据:
{"message":"Start parse dom","startFlag":true,"finishedFlag":false,"count":1}
在使用 Jackson 的 ObjectMapper.convertValue()
方法对 json 数据进行转换时, 出现了以下异常:
解决办法, 使用
ObjectMapper.readValue()
代替 ObjectMapper.convertValue()
对JSON数据进行反转, 即可解决问题。
Jackson:Cannot construct instance of **** (although at least one Creator exists):相关推荐
- Cannot construct instance of `com.*` (although at least one Creator exists): cannot deserialize
今天在写springboot单元测试的时候,序列化对象时出现一个错误: Cannot construct instance of `com.*.GeneralResponse` (although a ...
- Cannot construct instance of `******` (no Creators, like default construct,exist)
问题记录: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Req ...
- com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `x`
记录一下有点蠢的问题,序列化再次序列化就会出现这种问题. [2022-05-16 10:18:18.645] [ERROR] com.fu.common.global.GlobalExceptionH ...
- com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.zyw
问题如下 com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of com ...
- com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `
一 问题: Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct ins ...
- 【日常Exception】第二十二回:构造函数异常Cannot construct instance of `xx.xxx` (no Creators, like default construct
热门系列: 程序人生,精彩抢先看 1.问题 近期忙于开发,自测时发现了如题的一个异常.主要报错信息先贴一下: with root cause com.fasterxml.jackson.databin ...
- Json 错误com.fasterxml.jackson.databind.exc.MismatchedInputException:Cannot construct instance of
在把json数据转换成对象的时候出现这个错误 错误日志 com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot cons ...
- Redis缓存写入数据,解决Could not read JSON: Cannot construct instance of `xxx.xxDTO`的问题
场景: 使用 redis 存取对象的时候报错,报错信息如下: :40 - 捕捉的异常信息:Could not read JSON: Cannot construct instance of `co ...
- 解决 Can not construct instance of `xxxxx`
项目中使用了Lombok,这次升级之后,出现了如下问题: Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not ...
最新文章
- 联机日志损坏的解决办法
- Github Pages + Jekyll 独立博客一小时快速搭建上线指南
- java cunstructor_参加JavaScript面试,必须搞懂的问题(推荐)
- 必须声明标量变量_Excel VBA解读(136): 在用户定义函数中的变体、引用、数组、计算表达式、标量...
- 微课|《Python编程基础与案例集锦(中学版)》第2章(1)
- 【spring】spring的事务传播性 hibernate/jpa等的事务隔离性
- css预处理器_【第十一课】初尝CSS的预处理器
- MyEclipse8.6安装svn插件
- Python豆瓣书籍信息爬虫
- UML--构件图详解
- 【UE4_蓝图】录制麦克风声音/系统声音并输出保存WAV文件
- C语言面试题---函数(一)
- 1097: 蛇行矩阵
- 物联网应用之远程控制
- Unity 知识点 - 3D游戏 - 视角跟随和键盘移动
- Linux的任督二脉之内存管理线上微信群直播报名(2018.1.29-2.2)
- B站 根据BV 获取av号 api
- vue使用高德地图的搜索地址和拖拽选址
- uo和o的区别和用法_拼音o与uo如何区别使用
- 使用Spring JPA中Page、Pageable接口和Sort类完成分页排序