@XmlEnumValue 的杰克逊 jaxb 注释

Man*_*i H 4 java json jaxb

我在生成的类中有一个 @XmlEnumValue,我想测试一个 JSON 消息(我将在 JSON 消息中传递必须映射到 @XmlEnumValue 的值)并查看我的值是否被映射。但我无法做到这一点。我通过添加以下代码解决了读取@XmlElement 的类似问题。是否还有支持 @XmlEnumValue 的类似方法???我正在寻找这样的注释属性名称..

 <bean id="jaxbAnnotationInspector"
    class="org.codehaus.jackson.xc.JaxbAnnotationIntrospector"/>
<bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper">
    <property name="annotationIntrospector" ref="jaxbAnnotationInspector"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

Sta*_*yuk 6

我们正在使用这样的配置来让它工作

@Bean
public ObjectMapper objectMapper()
{
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JaxbAnnotationModule());
    return objectMapper;
}
Run Code Online (Sandbox Code Playgroud)