How can I make Ant use JAXB 2.2.x instead of Java 6 SE JAXB classes in javac?

好久不见. 提交于 2019-12-04 17:21:58
Peter Butkovic

I believe concept of endorsed library folder is your friend.

Namely switch:

<compilerarg value="-Djava.endorsed.dirs=/some/path/lib/endorsed"/>

Those jars present in the endorsed are to be considered prio to any other classes loaded (I believe).

For more complete sample see the correct answer on: How to make Ant prefer classes from a linked JAR over JDK classes?

Just add jaxb 2.2 implementation (e.g. jaxb-impl.2.2.5) to the compiler's classpath

<compilerarg value="-cp path_to_jaxb2_jar"/>

that will be enough, JAXB will automatically disover the new JAXB provider by information from jar's META-INF/services/ and use it instead of default internal provider. See JAXBContext.newInstance API "Discovery of JAXB implementation"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!