-
-
Save samaddico/7de528de7f8d3e2843aaa338585bd83f to your computer and use it in GitHub Desktop.
How to get Java POJOs, generated from schema files, to implement custom interfaces via maven plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<jxb:bindings version="1.0" | |
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:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance" | |
jxb:extensionBindingPrefixes="xjc"> | |
<jxb:bindings schemaLocation="../schema/yourSchemaFile.xsd"> | |
<jxb:bindings node="//xs:complexType[@name='SomeElementNameFromYourSchemaFile']"> | |
<inheritance:implements>com.your.pojos.CommonInterface</inheritance:implements> | |
</jxb:bindings> | |
</jxb:bindings> | |
</jxb:bindings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | |
http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<properties> | |
<cxf.version>2.7.7</cxf.version> | |
<cxf.xjc.version>2.3.0</cxf.xjc.version> | |
</properties> | |
<build> | |
<plugins> | |
<!-- Used to generate source code based on XSD (schema) file --> | |
<!-- http://cxf.apache.org/cxf-xjc-plugin.html --> | |
<plugin> | |
<groupId>org.apache.cxf</groupId> | |
<artifactId>cxf-xjc-plugin</artifactId> | |
<version>${cxf.xjc.version}</version> | |
<configuration> | |
<extensions> | |
<extension>org.jvnet.jaxb2_commons:jaxb2-basics:0.6.4</extension> | |
</extensions> | |
</configuration> | |
<executions> | |
<execution> | |
<id>generate-xsd-sources</id> | |
<phase>generate-sources</phase> | |
<goals> | |
<goal>xsdtojava</goal> | |
</goals> | |
<configuration> | |
<sourceRoot>${basedir}/target/generated-sources/cxf-xjc/</sourceRoot> | |
<xsdOptions> | |
<xsdOption> | |
<xsd>${basedir}/src/main/resources/schema/yourSchemaFile.xsd</xsd> | |
<bindingFile>${basedir}/src/main/resources/bindings/customBindingFile.xjb</bindingFile> | |
<packagename>com.your.pojos</packagename> | |
<extension>true</extension> | |
<extensionArgs> | |
<extensionArg>-Xinheritance</extensionArg> | |
</extensionArgs> | |
</xsdOption> | |
</xsdOptions> | |
</configuration> | |
</execution> | |
</executions> | |
<dependencies> | |
<dependency> | |
<groupId>commons-logging</groupId> | |
<artifactId>commons-logging</artifactId> | |
<version>1.1.3</version> | |
<scope>runtime</scope> | |
</dependency> | |
<dependency> | |
<groupId>commons-lang</groupId> | |
<artifactId>commons-lang</artifactId> | |
<version>2.6</version> | |
<scope>runtime</scope> | |
</dependency> | |
</dependencies> | |
</plugin> | |
</plugins> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ your-project-folder | |
- pom.xml | |
+ src | |
+ main | |
+ resources | |
+ bindings | |
- customBindingFile.xjb | |
+ schema | |
- yourSchemaFile.xjb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment