Difference of Maven JAXB plugins
Let's summarize. We have/had:
- the maven-jaxb2-plugin (https://github.com/highsource/maven-jaxb2-plugin)
the maven-jaxb-plugin (https://jaxb.dev.java.net/jaxb-maven2-plugin/)- the jaxb2-maven-plugin (https://github.com/mojohaus/jaxb2-maven-plugin)
Based on the comments of this thread, I've always used the maven-jaxb2-plugin (i.e. plugin #1):
Concerning the
org.jvnet.jaxb2.maven2:maven-jaxb2-plugin
versus
com.sun.tools.xjc.maven2:maven-jaxb-plugin,
from my point of view it's definitely
the first one
(http://maven-jaxb2-plugin.java.net/).This plugin has much more features
than
com.sun.tools.xjc.maven2:maven-jaxb-plugin,
the development is active. Finally,
I'm one of the authors :) and I'd say
we keep in touch with JAXB developers
and users and react to the latests
features/requests.
And indeed, the plugin #2 is dead. And because I've always been happy with #1, I've never used plugin #3 so can't really say anything about it. Just in case, here is a working configuration for plugin #1:
<project>
...
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
maven-jaxb2-plugin VS jaxb2-maven-plugin for multiple schemas
General advice: specify your packages in bindings.xjb
rather than in different executions with individual generatePackage
s.
<jxb:bindings schemaLocation="common1.xsd" node="/xsd:schema">
<jxb:schemaBindings>
<jxb:package name="mypackage.commonclasses"/>
</jxb:schemaBindings>
</jxb:bindings>
generatePackage
does not really work well with multiple schemas.
And please file a bug in
https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN
citing the problem with the multiple schemas and Eclipse. I'll take a look into it.
ps. SO disclaimer: I'm the author of maven-jaxb2-plugin
.
maven: which jaxb plugin to use?
There was a question that you could find helpful: Difference of Maven JAXB plugins.
Truly, the com.sun.tools.xjc.maven2:maven-jaxb-plugin
seems to be dead, it also offers few configuration options. I used it for a while, then switched to org.codehaus.mojo:jaxb2-maven-plugin
when I found a need to customize the generation to the extent the Sun's plugin could not cope with.
I haven't used the org.codehaus.mojo:xjc-maven-plugin
, but it seems to be a subset of the more versatile org.codehaus.mojo:jaxb2-maven-plugin
. As for the last one, the org.jvnet.jaxb2.maven2:maven-jaxb2-plugin
, no personal experience, either, but the dead links on the terse documentation page are not encouraging.
which jaxb plugin to use?
maven-jaxb-plugin
supports jaxb1.0 and this has not been updated since June 2005.
The maven-jaxb2-plugin
supports JAXB 2.1.
See more on this thread
What Maven2 plugins are available for JAXB2?
I found the following to be working well enough for my system.
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
</plugin>
Related Topics
Java.Io.Ioexception: Mark/Reset Not Supported
Run Java Application at Windows Startup
How to Serialize Joda Datetime with Jackson JSON Processor
How to Combine Two Lists into a Map (Java)
Reversing a String with Recursion in Java
Differencebetween the Float and Integer Data Type When the Size Is the Same
Using Powermockito.Whennew() Is Not Getting Mocked and Original Method Is Called
Why to Use Stringbuffer in Java Instead of the String Concatenation Operator
How to Write a Basic Swap Function in Java
What Is the Fastest Way to Compare Two Sets in Java
Instantiating Object of Type Parameter
Java Properties Utf-8 Encoding in Eclipse
Generating a Jaxb Class That Implements an Interface
How to Maintain Bi-Directional Relationships with Spring Data Rest and JPA
Printing Debug Info on Errors with Java 8 Lambda Expressions