Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jvnet maven plugin jaxb classes to implement serializable interface

Tags:

jaxb

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.

like image 505
Manu Avatar asked Sep 03 '25 05:09

Manu


1 Answers

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>
like image 62
jtomaszk Avatar answered Sep 05 '25 01:09

jtomaszk