com.fasterxml.jackson.databind.JsonMappingException:No suitable constructor found for type
来源:互联网 发布:出口退税算法 编辑:程序博客网 时间:2024/05/18 06:27
1.有可能是反序列的类确实没有默认构造方法,检查一下。
2.因为我遇到的问题不属于1的情况(最后发现是内部类的问题),首先我是建立了这样一个类,作用是作一个序列化和反序列化的测试:
public class Test { @org.junit.Test public void main() throws Exception { Seiral seiral = new Seiral(); seiral.setId("1"); seiral.setName("hhh"); ObjectMapper mapper = new ObjectMapper(); String ooo = mapper.writeValueAsString(seiral); System.out.println(ooo); Seiral ss = mapper.readValue(ooo, Seiral.class); System.out.println(ss); } public class Seiral implements Serializable { private static final long serialVersionUID = 1L; private String id; private transient String name; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return "id:" + id + ", name:" + name; }}
然后运行之后发现这个错误
com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com.bonc.vbap.data.dataset.Test$Seiral]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?) at [Source: {"id":"11111","name":"test"}; line: 1, column: 2] at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148).....
说是反序列化的类没有constructor 或者 creator,然后我把内部类单独放到外面,新建一个类,这个问题就没有了,具体是什么原因我也没有深究。
阅读全文
0 0
- com.fasterxml.jackson.databind.JsonMappingException:No suitable constructor found for type
- com.fasterxml.jackson.databind.JsonMappingException: No serializer found for
- com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class ...
- JsonMappingException: No suitable constructor found for type
- com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.apache.ibati
- org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type [si
- 解决com.fasterxml.jackson.databind.JsonMappingException: No suitable 以 Jackson 处理复杂类型(List,map)两种方法
- 【jackson 异常】com.fasterxml.jackson.databind.JsonMappingException异常处理
- json异常com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type #657
- zeppelin spark interpreter异常 com.fasterxml.jackson.databind.JsonMappingException
- 关于springmvc中jackson的No suitable constructor found for type错误
- No suitable constructor found for type [simple type, class com.bonc.vbap.dataservice.core.metadata.i
- JackSon将json串转成List<Object>,异常com.fasterxml.jackson.databind.JsonMappingException
- java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType
- nested exception is com.fasterxml.jackson.databind.JsonMappingException: Conflicting getter definiti
- com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize out of START_ARRAY token
- Json转对象失败:"No suitable constructor found for type [simple type, class com.test.faster.domain.respons
- jackson.databind之 com.fasterxml.jackson.databind.ser...错误
- sql语句表关联
- shell关于sed,awk日志分割
- 技术文章 | 将鼠标移动模式用于谎言检测
- 用dos命令如何查看指定端口是否正常运行
- response状态码
- com.fasterxml.jackson.databind.JsonMappingException:No suitable constructor found for type
- Hive分析窗口函数(一) SUM,AVG,MIN,MAX
- MUI evalJS跨webview回传参或执行方法
- 微信小程序开发 ---3
- android.content.ActivityNotFoundException: Unable to find explicit activity class解决办法
- spring boot mybatis 注解sql
- React 1 入门教程(改)
- 我的工作备忘2
- Kotlin