- Using Jaxb 2.1 to generate java code from .xsd
- Jaxb2-basics plug-in is used
Wants to have generated Class Student to implement Comparable.
public class Student implements Serializable, Comparable<Students> { ... //bean class... public int compareTo(Student other) { ..... return somevalue; } }
XSD:
<?xml version="1.0" encoding="UTF-8"?><jxb:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:ci="http://jaxb.dev.java.net/plugin/code-injector"
xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
jxb:version="2.1">
<jxb:bindings>
<jxb:globalBindings>
<jxb:javaType name="org.joda.time.LocalDate" xmlType="xs:date"
parseMethod="Javax.xml.bind.DatatypeConverter.parseDateTime"
printMethod="Javax.xml.bind.DatatypeConverter.parseDateTime" />
<xjc:serializable uid="12343" />
</jxb:globalBindings>
</jxb:bindings>
<jxb:bindings schemaLocation="Student.xsd"
version="1.0" node="/xs:schema">
<jxb:bindings node="//xs:element[@name='Student']/xs:complexType">
<inheritance:implements>java.lang.Comparable<Student></inheritance:implements>
<ci:code>public int compareTo(Student other) {
return somevalue;}</ci:code>
</jxb:bindings>
Plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<arguments>-extensions</arguments>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaincludes>
<include>
Student.xsd
</include>
</schemaincludes>
<bindingDirectory>src/main/resources</bindingDirectory>
<bindingincludes>
<include>
Student.xjb
</include>
</bindingincludes>
<packageName>com.test.model.example</packageName>
<outputDirectory>src/main/java </outputDirectory>
</configuration>
</plugin>
Error: Could not process schema files in directory
Unable to parse input schema(s). Error messages should have been provided. (org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.3:generate:default:generate-sources)org.apache.maven.plugin.MojoExecutionException: Unable to parse input schema(s). Error messages should have been provided. at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:55) at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:40)
I am missing something. Any help to resolve is appreciated.
I don't see where you configure JAXB2 Basics in your
pom.xml
.Here's a guide for maven-jaxb2-plugin. TL;DR:
You're using jaxb2-maven-plugin, I could not find a guide for using XJC plugins in their documentation, but there's this answer