gpt4 book ai didi

java - 升级库版本后Eclipse编译器错误

转载 作者:行者123 更新时间:2023-12-01 13:19:30 25 4
gpt4 key购买 nike

我有 Jackson 1.8.2,除了嵌套的 geo_position 属性之外,一切都正常。

浏览完一些SO问题后,我已经升级到Jackson 1.9.x,现在Jackson设法识别Position嵌套类,但提示纬度原始 float 属性。

此外,当我升级到新的 Jackson 版本后尝试编译项目时,Eclipse 给出了一个奇怪的错误:尝试降级回 1.8.2,但没有成功。奇怪的是,没有实际错误,并且项目的验证进行得很好。

enter image description here

堆栈跟踪:

org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "latitude" (Class task.Position), not marked as ignorable
at [Source: java.io.StringReader@14de991; line: 1, column: 64] (through reference chain: task.ResultSet["results"]->task.Location["geo_position"]->task.Position["latitude"])null

at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:659)
at org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanDeserializer.java:1365)
at org.codehaus.jackson.map.deser.BeanDeserializer._handleUnknown(BeanDeserializer.java:725)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:703)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:194)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:30)
at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
at task.JSONParser.fromNative(JSONParser.java:24)
at task.RESTClient.main(RESTClient.java:85)

代码: https://github.com/BeOleg/JavaRestClient

最佳答案

您需要使用 @JsonIgnoreProperties 注解 task.Position 以忽略您不需要的属性。

无法识别的字段“纬度”(类任务.Position),未标记为可忽略

关于java - 升级库版本后Eclipse编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22158660/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com