标签:table source mat lis bind sage AC exception serialize
在使用ObjectMapper将json转对象,调用mapper.readValue(jsonStr, XwjUser.class)时,报如下错:
com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of entity.XwjUser: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?) at [Source: {"id":1,"message":"Hello World","sendTime":1525162183195,"intList":null}; line: 1, column: 2] at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:261) at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:1456) at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1012) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1203) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:314) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:148) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3789) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2833) at testJson.TestObjectMapper.testObj(TestObjectMapper.java:47) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
....
解决办法:在XwjUser实体类中,加入无参构造器,即可解决
标签:table source mat lis bind sage AC exception serialize
原文地址:https://www.cnblogs.com/xuwenjin/p/8976529.html