2

I have a Maven project with XJC goals for model generation from XSD schema. I would like that in the generated schemas there are the equals and hashCode methods that are also generated.

I tried that:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>xjc_bonjour</id>
            <goals>
                <goal>xjc</goal>
            </goals>
            <configuration>
                <sources>
                    <source>${project.basedir}/src/main/resources/xsd/bonjour</source>
                </sources>
                <packageName>xxx.jobs.bonjour.schema</packageName>
            </configuration>
        </execution>
    </executions>
</plugin>

and

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.8.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <extension>true</extension>
                <generatePackage>xxx.jobs.bonjour.schema</generatePackage>
                <args>
                    <arg>-Xequals</arg>
                    <arg>-XhashCode</arg>
                </args>
                <plugins>
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics</artifactId>
                        <version>0.6.4</version>
                    </plugin>
                </plugins>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.jvnet.jaxb2_commons</groupId>
        <artifactId>jaxb2-basics-runtime</artifactId>
        <version>0.6.4</version>
    </dependency>
</dependencies>

I don't really know what is the problem here, when I do a maven generated ressources, the equals and the hashCode methods are not in bonjour model.

SilverNak
  • 3,283
  • 4
  • 28
  • 44
Fosfor
  • 191
  • 1
  • 2
  • 17
  • I recently added on answer on this, which was related to invoking this plugin using command line argument . See if that helps you https://stackoverflow.com/questions/46550756/programmatically-use-wsimport-with-jaxb-plugins-without-maven-or-ant/46645680#46645680 – Optional Oct 31 '17 at 16:49

0 Answers0