jackson error 含义log

简介:

1. 反序列化失败,类型不匹配

  View Code

这段错误是因为给出的filed是String类型,而序列化的是字符串对应的为{},即使一个object。

 

2. 不是public的filed以及没有getter

com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class com.test.json.jackson.User and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )

当序列化的时候,即将POJO转换为json的时候,需要有个getter方法。

 

3. 重写了构造方法但没有生命无参构造函数

com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com.test.json.jackson.User]: can not instantiate from JSON object (need to add/enable type information?)
 at [Source: java.io.StringReader@5f2108b5; line: 1, column: 2]

反序列化的时候,jackson需要通过无参构造函数来创建POJO。如果这时候你添加了构造函数并且带有参数,则无参构造函数被掩盖,则报错。

 

4.字符串中的字段和要转换POJO的字段不匹配,如果忽略不认识的字段,需要设

@JsonIgnoreProperties(ignoreUnknown = true)
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "a" (class com.test.json.jackson.User), not marked as ignorable (one known property: "name"])
 at [Source: java.io.StringReader@75329a49; line: 1, column: 9] (through reference chain: com.test.json.jackson.User["a"])

    at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79)
    at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:555)

 本文转自Ryan.Miao博客园博客,原文链接:http://www.cnblogs.com/woshimrf/p/5845364.html,如需转载请自行联系原作者

相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
8天前
|
Android开发
双击eclipse提示an error has occurred See the log file E:\javatool\eclipse-mars-2\configuration\156991769
双击eclipse提示an error has occurred See the log file E:\javatool\eclipse-mars-2\configuration\156991769
30 1
|
8天前
|
SQL JSON Kubernetes
Seata常见问题之服务端 error日志没有输出,客户端执行sql报错如何解决
Seata 是一个开源的分布式事务解决方案,旨在提供高效且简单的事务协调机制,以解决微服务架构下跨服务调用(分布式场景)的一致性问题。以下是Seata常见问题的一个合集
131 0
|
7月前
|
Java 程序员
【日志级别】log4j的8个日志级别(OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、ALL)
【日志级别】log4j的8个日志级别(OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、ALL)
423 0
|
7月前
批量打印 SAP CRM 系统所有包含 Error Message Log 的 订单
批量打印 SAP CRM 系统所有包含 Error Message Log 的 订单
34 0
|
8月前
|
应用服务中间件 PHP nginx
PHP ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
PHP ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
65 1
|
9月前
|
Java
成功解决:ERROR StatusLogger No log4j2 configuration file found.
成功解决:ERROR StatusLogger No log4j2 configuration file found.
|
11月前
|
存储 设计模式 缓存
详解MySQL Error Log
Error Log是MySQL的一个非常重要的日志,主要用来记录mysqld的启动和关闭,以及mysqld启动,关闭以及运行期间的诊断信息。本文主要对Error Log的初始化以及写入过程做一个详细的介绍。以下介绍基于MySQL 8.0.28。初始化日志服务的初始化代码调用堆栈如下:- mysqld_main   - init_error_log   //初始化日志子系统   - log_buil
详解MySQL Error Log
|
12月前
|
关系型数据库 MySQL
把log_error_verbosity设置为3,调试连接问题ERROR 2003 (HY000):ERROR 1045 (28000):
mysql 8里面使用global log_error_verbosity控制日志记录的详细程度
|
关系型数据库 MySQL
MySQL的Error日志是干什么的?底层原理是什么?
MySQL的Error日志是干什么的?底层原理是什么?
111 0
|
Java Maven
严重: Error configuring application listener of class org.springframework.web.util.Log4jConfigListener
严重: Error configuring application listener of class org.springframework.web.util.Log4jConfigListener
111 0
严重: Error configuring application listener of class org.springframework.web.util.Log4jConfigListener

热门文章

最新文章