今天在写springboot单元测试的时候,序列化对象时出现一个错误:

Cannot construct instance of `com.*.GeneralResponse` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)at [Source: (String)"{"transaction_id":"123"}"; line: 1, column: 2]
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.*.GeneralResponse` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)at [Source: (String)"{"transaction_id":"123"}"; line: 1, column: 2]

需要序列化的json串为:

{"transaction_id":"123"}

对象为:

@Getter
@Setter
@AllArgsConstructor
public class GeneralResponse {private String transactionId;
}

错误的原因是没有无参构造函数,json在转对象反序列化的时候,需要先初始化对象,默认调用无参构造函数,再赋值,在使用@Builder注解时必须搭配@AllArgsConstructor 和@NoArgsConstructor同时使用。

Cannot construct instance of `com.*` (although at least one Creator exists): cannot deserialize相关推荐

  1. Cannot construct instance of `com.*` (although at least one Creator exists): cannot deserializ

    今天开发的springboot项目的时候,当前端发出请求的时候,还没有进入controller层就爆出了这样的一个错误. Cannot construct instance of `com.***.* ...

  2. JSON parse error: Cannot construct instance of “xxx“(although at least one Creator exists)

    今天写SpringBoot出现一个错误 JSON parse error: Cannot construct instance of `priv.kuki.param.AddressListParam ...

  3. Can not construct instance of com.h.dog.entity.Message: no int/Int-argument constructor/factory meth

    org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Can not const ...

  4. com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `x`

    记录一下有点蠢的问题,序列化再次序列化就会出现这种问题. [2022-05-16 10:18:18.645] [ERROR] com.fu.common.global.GlobalExceptionH ...

  5. Jackson:Cannot construct instance of **** (although at least one Creator exists):

    Jackson:nested exception is java.lang.IllegalArgumentException: Cannot construct instance of **** (a ...

  6. com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.zyw

    问题如下 com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of com ...

  7. 【Redis 反序列化报错】 Cannot construct instance of `com.vt.common.Result` (no Creators, like default constr

    最近做了一个项目,数据量比较大,所以用到了 @Cacheable注解,嫌麻烦,百度找了相关配置,如下: 序列化配置@Beanpublic static RedisTemplate<String, ...

  8. Redis缓存写入数据,解决Could not read JSON: Cannot construct instance of `xxx.xxDTO`的问题

      场景: 使用 redis 存取对象的时候报错,报错信息如下: :40 - 捕捉的异常信息:Could not read JSON: Cannot construct instance of `co ...

  9. 解决 Can not construct instance of `xxxxx`

    项目中使用了Lombok,这次升级之后,出现了如下问题: Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not ...

最新文章

  1. 5GtoB即将迎来规模商用,如何共创行业新价值?
  2. 两台电脑cpu序列号一样_如何正确使用苹果电脑?
  3. cordova 蓝牙_Ionic通过Cordova插件使用设备能力
  4. python perl 日本的应用_将perl-soap应用程序移植到python
  5. java 读取 邮件 附件,JavaMail 中对附件下载的处理
  6. centos7 安装sqlserver驱动以及扩展
  7. hdu2492 Ping pong
  8. SPSS简介【SPSS 004期】
  9. Oracle技术之使用dd复制asm中文件
  10. r语言如何计算t分布临界值_医学统计与R语言:四格表卡方还需要连续校正吗?...
  11. (精)广东工业大学《数据可视化技术》 2018实验报告
  12. 12Cr1MoVR是什么材质12Cr1MoVR钢板简介12Cr1MoVR化学成分钢板应用
  13. 注册AWS账号创建EC2免费套餐详细教程
  14. 用devc++表白_「你表白,我宠你」520—实验猿的表白日,小析姐的“宠粉”节
  15. html读秒倒计时,读秒倒计时
  16. el-table合计
  17. Ubuntu下搭建第一台hadoop输入start-dfs.sh出现Permission denied (publickey,password)的问题
  18. 如何利用redis 实现分布式项目枷锁功能
  19. CHOPS 音乐驱动动画2
  20. 李想骂街之后 理想IPO真能渡劫?

热门文章

  1. 数据科学必备Pandas冷门却超级实用的技巧
  2. 转载:千万别看`小心让你哭
  3. Android6.0修改以太网IP
  4. SHA256安全散列算法的Javascript实现
  5. 无法在windows资源管理器中查看此FTP站点
  6. 《重学Java设计模式》作者开始录视频了
  7. (原創) Quartus II安裝新觀念:如何將Quartus II安裝在VirtualBox內? (SOC) (Quartus II) (VirtualBox)...
  8. 基于ssm的crm系统开源_基于云的CRM软件工具
  9. python光棍节快乐_2020年祝光棍节快乐的祝福语18条
  10. SQL SERVER 2005数据导入导出报“错误 0xc00470fe 数据流任务 产品级别对于 组件“源 - TestDB01$”(1) 而言不足”