蔡松成 發表於 2018-4-18 22:06:00

關於小黑盒跳出的BUG問題

想請教一下
如果出現這種問題的話 是裝備出錯
可是該從哪下手呢

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token
at ; line: 1, column: 1]
...

求大神指點迷津

蔡松成 發表於 2018-4-18 22:12:37

還有這種不一樣的

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "info" (class server.StructSetItem), not marked as ignorable (5 known properties: "setItemID", "setItemStat", "itemIDs", "completeCount", "setItemName"])
at (through reference chain: server.StructSetItem["info"])
        at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:62)
        at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:834)
        at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1093)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1477)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1455)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:282)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2842)
        at server.MapleItemInformationProvider.getSetItem(MapleItemInformationProvider.java:1189)
        at client.PlayerStats.handleEquipSetStats(PlayerStats.java:6535)
        at client.PlayerStats.recalcLocalStats(PlayerStats.java:384)
        at client.PlayerStats.recalcLocalStats(PlayerStats.java:148)
        at client.MapleCharacter.registerEffect(MapleCharacter.java:3018)
        at server.MapleStatEffect.applyBuffEffect(MapleStatEffect.java:4278)
        at server.MapleStatEffect.applyTo(MapleStatEffect.java:519)
        at server.MapleStatEffect.applyTo(MapleStatEffect.java:203)
        at server.MapleStatEffect.applyTo(MapleStatEffect.java:181)
        at handling.channel.handler.DamageParse.applyAttack(DamageParse.java:427)
        at handling.channel.handler.PlayerHandler.closeRangeAttack(PlayerHandler.java:924)
        at handling.channel.handler.PlayerHandler.closeRangeAttack(PlayerHandler.java:819)
        at handling.channel.handler.PlayerHandler.attackProcessing(PlayerHandler.java:792)
        at handling.MapleServerHandler.handlePacket(MapleServerHandler.java:222)
        at handling.MapleServerHandler.channelRead(MapleServerHandler.java:1184)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:651)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:574)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:488)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:450)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
        at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
        at java.lang.Thread.run(Thread.java:745)

ak1254664 發表於 2018-4-18 23:36:41

本帖最後由 ak1254664 於 2018-4-18 23:40 編輯

蔡松成 發表於 2018-4-18 22:12 static/image/common/back.gif
還有這種不一樣的

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized fie ...
Unrecognized field, not marked as ignorable

該錯誤的意思是說,不能夠識別的字段沒有標示為可忽略。
出現該問題的原因就是JSON中包含了目標Java對像沒有的屬性。


-----
1.符合屬性。看是目標中新增屬性,或是傳入時候不要包含吧。

格式化輸入內容,保證傳入的JSON串不包含目標對象的沒有的屬性。

2. 設定忽略不存在的屬性。挺暴力的,如果遊戲功能沒有異常,用這個直接設置忽略就行吧。

@JsonIgnoreProperties(ignoreUnknown = true) 在目標對象的類級別上加上該註解,並配置ignoreUnknown = true,則Jackson在反序列化的時候,會忽略該目標對像不存在的屬性。


3. 全局一律忽略。超暴力的,最好不要用,要的話用2就好。

全局DeserializationFeature配置
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
配置該objectMapper在反序列化時,忽略目標對像沒有的屬性。
凡是使用該objectMapper反序列化時,都會擁有該特性。

-----------

https://blog.csdn.net/gavincook/article/details/46574661

蔡松成 發表於 2018-4-19 12:41:20

ak1254664 發表於 2018-4-18 23:36 static/image/common/back.gif
Unrecognized field, not marked as ignorable

該錯誤的意思是說,不能夠識別的字段沒有標示為可忽略。


非常謝謝你的答覆
馬上來研究 :loveliness:
頁: [1]
查看完整版本: 關於小黑盒跳出的BUG問題