本文介绍了Jackson ObjectMapper() 构造函数抛出 NoSuchMethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Jackson 示例代码来反序列化 POJO:

I'm using Jackson sample code to deserialize a POJO:

ObjectMapper m = new ObjectMapper();

这一行抛出一个 NoSuchMethodError:

This line throws a NoSuchMethodError:

Exception in thread "main" java.lang.NoSuchMethodError: org.codehaus.jackson.type.JavaType.<init>(Ljava/lang/Class;)V
    at org.codehaus.jackson.map.type.TypeBase.<init>(TypeBase.java:15)
    at org.codehaus.jackson.map.type.SimpleType.<init>(SimpleType.java:45)
    at org.codehaus.jackson.map.type.SimpleType.<init>(SimpleType.java:40)
    at org.codehaus.jackson.map.type.TypeBindings.<clinit>(TypeBindings.java:18)
    at org.codehaus.jackson.map.type.TypeFactory._fromType(TypeFactory.java:525)
    at org.codehaus.jackson.map.type.TypeFactory.type(TypeFactory.java:61)
    at org.codehaus.jackson.map.ObjectMapper.<clinit>(ObjectMapper.java:179)
    at com.me.util.ctrl.BillingJobStatus.fromJson(BillingJobStatus.java:37)

我不明白

推荐答案

我猜您的 Jackson JAR 不同步.JavaType 类在 jackson-core JAR 中,ObjectMapper 类在 jackson-mapper 中.

I'm guessing your Jackson JARs are out of sync. The JavaType class is in the jackson-core JAR, and the ObjectMapper class is in jackson-mapper.

确保它们的版本相同.

这篇关于Jackson ObjectMapper() 构造函数抛出 NoSuchMethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 06:00