设置JaxbAnnotationIntrospector会导致错误

时间:2015-02-02 16:47:10

标签: java jaxb jackson

我创建了一个扩展ObjectMapper的自定义对象映射器。我设置了内省探测器:

public CustomObjectMapper()
    {
        super();
        AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(getTypeFactory());
        setAnnotationIntrospector(introspector);
    }

并收到以下错误:

Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.annotation.JsonFormat$Value: method <init>()V not found
    at com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector.<clinit>(JaxbAnnotationIntrospector.java:85)
    at com.company.project.client.jackson.CustomObjectMapper.<init>(CustomObjectMapper.java:18)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
    ... 38 more

一切正常,直到我将杰克逊从2.0.1更新到2.4.5。为什么我会在Jackson 2.4中设置AnnotationIntrospector?

更新。将库更改为2.4.0解决了这个问题。

0 个答案:

没有答案