Dealing with duplicate classes with multiple maven-jaxb2-plugin executions using different schemas with the same base schema

One solution could be to add a separate binding file (*.xjb) to each execution in order to generate specific classes (and avoiding name clash).

<configuration>
  <bindingDirectory>src/main/bindings</bindingDirectory>
  <bindingIncludes>
    <include>unifiedServices.xjb</include>
  </bindingIncludes>

See the XJC documentation , but it is for instance possible to add a suffix to all class names:

<schemaBindings>
  <nameXmlTransform>
    <typeName suffix="_SuffixA"/>
  </nameXmlTransform>
</schemaBindings>

Doing so, if the same "Foo" type of namespace "company.com" is part of a same common schema imported by several wsdl, you could end up with distinct classes:

  • com.company.Foo_SuffixA (generated in "unifiedServices")
  • com.company.Foo_SuffixB (generated in "iuclp")