1

我使用 xjc maven 插件在 WSDL 中生成类型。按照我的配置:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <id>auth-service-type-generation</id>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <phase>generate-sources</phase>
                    <configuration>
                        <encoding>UTF8</encoding>
                        <schemaDirectory>${wsdl.location}</schemaDirectory>
                        <schemaFiles>${wsdl.auth.srv.file.name}</schemaFiles>
                        <xmlschema>false</xmlschema>
                        <wsdl>true</wsdl>
                        <nv>false</nv>
                        <bindingDirectory>${project.basedir}/src/main/resources/jaxb/</bindingDirectory>
                        <bindingFiles>jaxb_bindings.xjb</bindingFiles>
                    </configuration>
                </execution>
            </executions>
        </plugin>

jaxb_bindings.xjb 的内容:

<jaxb:bindings version="2.0"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
    <jaxb:bindings>
        <jaxb:globalBindings generateElementProperty="false"/>
    </jaxb:bindings>
</jaxb:bindings>

我使用此绑定摆脱了 JAXBElement,但它仍然会生成。我的设置有什么问题,或者是否有另一种方法可以在没有 JAXBElement 的情况下在我的 WSDL 中生成类型?

4

1 回答 1

1

您的配置中似乎缺少属性:schemaLocationnode.

<jaxb:bindings version="2.0"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
   <jaxb:bindings schemaLocation="../path/your.xsd" node="/xs:schema">
      <jaxb:globalBindings generateElementProperty="false"/>
   </jaxb:bindings>
</jaxb:bindings>
于 2015-03-20T12:08:16.610 回答