简体   繁体   English

@XmlEnumValue 的 jackson jaxb 注释

[英]jackson jaxb annotation for @XmlEnumValue

I have an @XmlEnumValue in a generated class and I want to test a JSON mesage (I will pass in JSON message the value that must be mapped to @XmlEnumValue) and see if my value is getting mapped.我在生成的类中有一个 @XmlEnumValue,我想测试一个 JSON 消息(我将在 JSON 消息中传递必须映射到 @XmlEnumValue 的值)并查看我的值是否被映射。 But I am unable to do this.I Solved a similar problem to read @XmlElement by adding below code.但我无法做到这一点。我通过添加以下代码解决了读取@XmlElement 的类似问题。 Id there any similar approach for supporting @XmlEnumValue also ???是否有任何类似的方法来支持 @XmlEnumValue ??? I am looking for such annotaion property name..我正在寻找这样的注释属性名称..

 <bean id="jaxbAnnotationInspector"
    class="org.codehaus.jackson.xc.JaxbAnnotationIntrospector"/>
<bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper">
    <property name="annotationIntrospector" ref="jaxbAnnotationInspector"/>
</bean>

We're using such configuration to get it working我们正在使用这样的配置来让它工作

@Bean
public ObjectMapper objectMapper()
{
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JaxbAnnotationModule());
    return objectMapper;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM