4

I am using maven plug jvnet

<groupId>org.jvnet.jaxb2.maven2</groupId>
 <artifactId>maven-jaxb2-plugin</artifactId>

To generate jaxb classes from xsd.

I want all jaxb classes have to implement serializable interface. Please let me know how to do it.

Manu
  • 1,243
  • 5
  • 17
  • 43
  • possible duplicate of [How to generate classes from XSD that implements serializable?](http://stackoverflow.com/questions/3677088/how-to-generate-classes-from-xsd-that-implements-serializable) – lexicore Aug 21 '15 at 13:23
  • See also: http://stackoverflow.com/questions/1513972/how-to-generate-a-java-class-which-implements-serializable-interface-from-xsd-us?rq=1 – lexicore Aug 21 '15 at 13:24
  • See also: http://stackoverflow.com/questions/1271980/generating-a-jaxb-class-that-implements-an-interface?rq=1 – lexicore Aug 21 '15 at 13:25

1 Answers1

7

Just create a global.xjb file in yours bindingDirectory

binding

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings xmlns:jaxb="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:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:annox="http://annox.dev.java.net"
               xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
               version="2.1">
    <jaxb:globalBindings>        
        <xjc:serializable uid="-1"/>
    </jaxb:globalBindings>        
</jaxb:bindings>

sample plugin configuration

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.13.1</version>
    <executions>
        <execution>
            <id>generate</id>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <schemaDirectory>src/main/resources/xsd</schemaDirectory>
        <bindingDirectory>src/main/resources/xsd</bindingDirectory>
    </configuration>
</plugin>
jtomaszk
  • 9,223
  • 2
  • 28
  • 40