码迷,mamicode.com
首页 > 其他好文 > 详细

Jackson包依赖冲突,出现NoSuchMethodError异常

时间:2019-10-18 11:09:13      阅读:410      评论:0      收藏:0      [点我收藏+]

标签:abstract   lock   编译   contents   gen   header   for   head   array   

Jackson异常信息:java.lang.NoSuchMethodError

java.lang.NoSuchMethodError: com.fasterxml.jackson.datatype.joda.ser.JodaDateSerializerBase.findFormatOverrides(Lcom/fasterxml/jackson/databind/SerializerProvider;Lcom/fasterxml/jackson/databind/BeanProperty;Ljava/lang/Class;)Lcom/fasterxml/jackson/annotation/JsonFormat$Value;
java.lang.NoSuchMethodError: com.fasterxml.jackson.datatype.joda.ser.JodaDateSerializerBase.findFormatOverrides(Lcom/fasterxml/jackson/databind/SerializerProvider;Lcom/fasterxml/jackson/databind/BeanProperty;Ljava/lang/Class;)Lcom/fasterxml/jackson/annotation/JsonFormat$Value;
at com.fasterxml.jackson.datatype.joda.ser.JodaDateSerializerBase.createContextual(JodaDateSerializerBase.java:49)
at com.fasterxml.jackson.databind.SerializerProvider.handleSecondaryContextualization(SerializerProvider.java:944)
at com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:495)
at com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap.findAndAddSecondarySerializer(PropertySerializerMap.java:90)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer._findAndAddDynamic(ObjectArraySerializer.java:394)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeContents(ObjectArraySerializer.java:253)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:216)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:26)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:130)
at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:2383)
at com.fasterxml.jackson.core.base.GeneratorBase.writeObject(GeneratorBase.java:324)
at com.wormpex.fd.wclient.rpc 大专栏  Jackson包依赖冲突,出现NoSuchMethodError异常.dubbo.filter.AbstractAccessLogFilter$AccessLogSerializer.serialize(AbstractAccessLogFilter.java:350)
at com.wormpex.fd.wclient.rpc.dubbo.filter.AbstractAccessLogFilter$AccessLogSerializer.serialize(AbstractAccessLogFilter.java:282)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:130)
at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3559)
at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:2893)
at com.wormpex.common.json.JsonMapper.writeValue(JsonMapper.java:1011)
... 74 common frames omitted

分析

出现NoSuchMethodError,一般会有两种Case:

  1. jar包冲突,相同jar包,依赖多个版本

    这种情况往往是maven依赖导致的,编译时,可能会加载旧版本jar,导致运行时无法找到某个method
  2. class冲突,不同的jar包中,存在相同的包目录结构,相同class名称

    这种情况比较特殊。举个栗子
    某个工程依赖了jackson-3.1.2.jar, 同时这个工程又依赖了foo-1.1.0.jar
    如果foo包中也需要依赖jackson包,但是没有直接依赖,而是将jackson包中的类,以同包同类名拷贝到foo包中,
    当类加载时,可能会优先加载foo包中的jackson类,从而导致不会再加载jackson包中的类,最终运行时无法找到某个method

Jackson包依赖冲突,出现NoSuchMethodError异常

标签:abstract   lock   编译   contents   gen   header   for   head   array   

原文地址:https://www.cnblogs.com/wangziqiang123/p/11697018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!