java 如何修复 org.codehaus.jackson.map.exc.UnrecognizedPropertyException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16987543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix org.codehaus.Hymanson.map.exc.UnrecognizedPropertyException
提问by blue-sky
Here is the snippet of code that is causing the exception :
这是导致异常的代码片段:
org.springframework.web.client.RestTemplate rt
.getForObject(uri, type, vars);
The exception is :
例外是:
nested exception is org.codehaus.Hymanson.map.exc.UnrecognizedPropertyException: Unrecognized field "d" (Class com.xsd.myObj), not marked as ignorable
嵌套异常是 org.codehaus.Hymanson.map.exc.UnrecognizedPropertyException: Unrecognized field "d" (Class com.xsd.myObj),未标记为可忽略
Does this mean there is a field called "d" in the xml document being read that is expected to be in the java/xsd file ? What steps can I take to fix this error ?
这是否意味着正在读取的 xml 文档中有一个名为“d”的字段,该字段应该在 java/xsd 文件中?我可以采取哪些步骤来修复此错误?
回答by Chris
This means that there are get
and set
methods of an object in your class and Hymanson is unable to figureout the serialization and deserialization process.
这意味着您的类中有对象的方法get
和set
方法,而 Hymanson 无法弄清楚序列化和反序列化过程。
Use @JsonIgnore
if you don't want the property to be serialized.
使用@JsonIgnore
,如果你不希望属性被序列化。
If you would like to have this data serialized and deserialized, it could be a problem with polymorphic references. Check Hymanson's Annotation guidefor appropriate usage. You may be interested in @JsonTypeInfo
in such cases.
如果您希望对这些数据进行序列化和反序列化,则多态引用可能会出现问题。检查Hymanson 的 Annotation 指南以了解适当的用法。您可能对@JsonTypeInfo
此类情况感兴趣。