Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get maven to use a different JAXB library to one in JDK

Tags:

java

xml

maven

jaxb

I'm using java 1.6.0_14 which includes an implementation of the annotation javax.xml.bind.annotation.XmlElement. However the one in the JDK only applies to Method and Field.

I've found jaxb-api.jar version 2.2.3 permits this on Parameter too, so I want to use this version.

Problem is, I can't figure out how to get maven to use this one in preference to the one in the JDK so that when I am writing my code it doesn't complain that the annotation is being used in an invalid location.

Any suggestions?

like image 854
Dave Richardson Avatar asked Oct 20 '11 15:10

Dave Richardson


1 Answers

You have to use the Java endorsed override mechanism. I got this directly from the Apache CXF website.

JAXB is the default data binding for CXF. If you don't specify one of the other data bindings in your Spring configuration or through the API, you will get JAXB. Releases of CXF since 2.3.x have used the JDK7 default of JAXB 2.2, however Maven users running on JDK 6 will need to use the Java endorsed override mechanism to use JAXB 2.2 instead of JAXB 2.1.

http://cxf.apache.org/docs/jaxb.html first paragraph at the top. You basically download the new version of jaxb then tell the JRE/JDK to load that instead of the default implementation that it shipped with.

like image 171
emmmdeee Avatar answered Sep 27 '22 17:09

emmmdeee