3

Is there anyway to do auto name resolution here. I don't want static classes hence using the bindings. but I am getting errors when generating pojo

[ERROR] file:/C:/Projects/custom-mapping/transformer/src/main/resources/xsd/input2.xsd [71,51] org.xml.sax.SAXParseException: A class/interface with the same name "com.mypack.mapper.model.input.TradePartner" is already in use. Use a class customization to resolve this conflict.

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>2.5.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <packageName>com.mypack.mapper.model.input</packageName>
                <sources>
                    <source>src/main/resources/xsd/input.xsd</source>
                </sources>
                <xjbSources>
                    <xjbSource>src/main/resources/xsd/binding.xjb</xjbSource>
                </xjbSources>
            </configuration>
        </plugin>

where binding.xjb is

<jaxb:bindings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
version="2.1">
<jaxb:globalBindings localScoping="toplevel"/></jaxb:bindings>
Sajin Surendran
  • 248
  • 6
  • 17

1 Answers1

2

Try to put -XautoNameResolution argument into your <configuration>

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>2.5.0</version>
    <executions>
        <execution>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <arguments>
            <arg>-XautoNameResolution</arg>
        </arguments>
        <packageName>com.mypack.mapper.model.input</packageName>
        <sources>
            <source>src/main/resources/xsd/input.xsd</source>
        </sources>
        <xjbSources>
            <xjbSource>src/main/resources/xsd/binding.xjb</xjbSource>
        </xjbSources>
    </configuration>
</plugin>

It will generate classes with names like ConfilctClass1, ConfilctClass2 etc.