@使用spring时未调用JsonDeserialize

@使用spring时未调用JsonDeserialize,json,spring,jackson,cxf,Json,Spring,Jackson,Cxf,我正在使用Jackson 2.x和spring ws 4.0.6。 我已经使用CXF和配置的映射器配置了rest服务 <jaxrs:providers> <ref bean="jsonReader"/> </jaxrs:providers> } 我可以获得任意多个id-id1、id2、id3..,因此我无法创建具有字段名id1、id2等的pojo 我在我的POJO中注释了字段,如下所示 <bean id="jsonBo

我正在使用Jackson 2.x和spring ws 4.0.6。 我已经使用CXF和配置的映射器配置了rest服务

<jaxrs:providers>         
        <ref bean="jsonReader"/>
</jaxrs:providers>
}

我可以获得任意多个
id-id1、id2、id3..
,因此我无法创建具有字段名
id1、id2
等的pojo

我在我的POJO中注释了字段,如下所示

<bean id="jsonBodyReader" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider">
    <property name="mapper" ref="mapper"/>
</bean>

<bean id="mapper"
      class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean">
    <property name="annotationIntrospector">
        <bean class="com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector"/>
    </property>
    <property name="featuresToEnable">
        <array>
            <util:constant static-field="com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_WITH_ZONE_ID"/>
            <util:constant static-field="com.fasterxml.jackson.databind.MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES"/>
        </array>
    </property>
    <property name="featuresToDisable">
        <array>
            <util:constant static-field="com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS"/>
            <util:constant static-field="com.fasterxml.jackson.databind.SerializationFeature.WRITE_EMPTY_JSON_ARRAYS"/>
            <util:constant static-field="com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES"/>
        </array>
    </property>
    <property name="serializationInclusion" value="NON_NULL"/>
</bean>
@JsonDeserialize(using = CustDeserializer.class)
private List<HashMap<String,String>> identities;
public class CustDeserializer extends JsonDeserializer>> { @Override public List> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectCodec oc = jp.getCodec(); JsonNode node = oc.readTree(jp); List> identities = new ArrayList>(); for(int i=0;i> elem = node1.fields(); HashMap map= new HashMap(); while(elem.hasNext()){ Entry el = elem.next(); String name = el.getKey(); String value = el.getValue().asText(); map.put(name, value); } identities.add(map); } return identities; } 现在,当我调用rest服务时,列表中填充了包含键/值对的哈希映射。但是未调用
CustDeserializer
类,因此我无法自定义我的列表。默认情况下,它由Jackson的
CollectionDeserializer
转换

当我在一个独立的java程序中尝试同样的方法时,它可以工作,并且我的反序列化程序被调用

ObjectMapper mapper = new ObjectMapper();

    try {
        JsonRequest h = mapper.readValue(new File("request.json"), JsonRequest.class);
        System.out.println(h);
    }
输出:
JsonRequest[name=XYZ,identifications=[{id2=16777,id1=12345},{id3=12345}]

但是,当我在CXF和Spring的上下文中使用它时,它不起作用

ObjectMapper mapper = new ObjectMapper();

    try {
        JsonRequest h = mapper.readValue(new File("request.json"), JsonRequest.class);
        System.out.println(h);
    }