Is there any way to use maven to generate java classes from an XSD (similar to jaxb2-maven-plugin) but just simply generates pojos without the javax.xml annotations?
Asked
Active
Viewed 1,113 times
2 Answers
1
You can use XML-Beans. It is fairly easy.
How to include automatically xmlbeans generated code into maven jar?
http://mojo.codehaus.org/xmlbeans-maven-plugin/
Please refer to this for further clarification - http://blog.bdoughan.com/2012/01/how-does-jaxb-compare-to-xmlbeans.html
0
You can use Perl regex replacements on the xjc generated java to remove all the javax annotations and references as below:
$s =~ s/\@\w+\([^\(\)]+\)//smg;
$s =~ s/\@\w+\r\n//g;
$s =~ s/javax\.xml\.datatype\.XMLGregorianCalendar/java\.util\.Date/g;
$s =~ s/import javax.*;\r\n//g;
$s =~ s/XMLGregorianCalendar/Date/g;
It is not perfect in its treatment of spaces/carriage returns between annotations, but worked for me on a commercial project to generate the POJOs I needed.
See the full script here: https://github.com/ajbarber/JAXStripper

Water-whipper
- 1
- 1
-
Welcome to Stack Overflow! Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. See [here](https://meta.stackexchange.com/a/94027/285661) for instructions how to write *better* "link-based" answers. – GhostCat Aug 30 '17 at 14:53