3

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?

Greg Marut
  • 173
  • 2
  • 11

2 Answers2

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

Community
  • 1
  • 1
asg
  • 2,248
  • 3
  • 18
  • 26
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

  • 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