【问题标题】:JAXBElement generated even with generateElementProperty to false即使将 generateElementProperty 设置为 false,也会生成 JAXBElement
【发布时间】:2015-03-20 11:49:46
【问题描述】:

我使用 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 中生成类型?

【问题讨论】:

  • 你解决了吗?

标签: maven jaxb wsdl xjc jaxb2-maven-plugin


【解决方案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>

【讨论】:

  • 所以如果我有多个模式,我是否必须为每个模式复制标签?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-02
相关资源
最近更新 更多