I have an application, that my JAXB2 annotated classes are possibly stored in multiple JARs, and I am using them in my web app (which use Spring MVC with Spring OXM Jaxb2Marshaller to expose RESTful WS).
I would want to generate the XSD for all classes that is possibly be used in my WS. However, com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin
and org.codehaus.mojo:jaxb2-maven-plugin
are generating by inspecting the source code of the project but I want some similar solution which base on the runtime classes, as my POJOs are stored in other JARs, which APT will not be able to scan my code.
It is fine to generate the XSD in compile time, or by running the web app. Is there any solution?
Use
JAXBContext.generateSchema(...)
in the runtime.See this answer: