Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jackson jaxb annotation for @XmlEnumValue

Tags:

java

json

jaxb

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. But I am unable to do this.I Solved a similar problem to read @XmlElement by adding below code. Id there any similar approach for supporting @XmlEnumValue also ??? 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>
like image 631
Mannepalli H Avatar asked Nov 14 '25 20:11

Mannepalli H


1 Answers

We're using such configuration to get it working

@Bean
public ObjectMapper objectMapper()
{
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JaxbAnnotationModule());
    return objectMapper;
}
like image 83
StasKolodyuk Avatar answered Nov 17 '25 12:11

StasKolodyuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!