How to generate XSD for JaxB Java files in IntelliJ
Is there an easy way to do this. I have some classes annotated with
@XmlType
@XmlAccessorType(XmlAccessTy开发者_如何学编程pe.FIELD)
I am trying to lookup at the same time on internet.
If there isn't a way to do this in IntelliJ, then it is easy to do using the JAXB runtime APIs:
JAXBContext jaxbContext = JAXBContext.newInstance(Customer.class);
SchemaOutputResolver sor = new MySchemaOutputResolver();
jaxbContext.generateSchema(sor);
And
private class MySchemaOutputResolver extends SchemaOutputResolver {
public Result createOutput(String namespaceURI, String suggestedFileName) throws IOException {
File file = new File(suggestedFileName);
StreamResult result = new StreamResult(file);
result.setSystemId(file.toURI().toURL().toString());
return result;
}
}
For More Information:
- http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JAXB/GenerateSchema
You can use schemagen
精彩评论