Thrown by JAXB : Property "Any" is already defined. Use <jaxb:property> to resolve this conflict.

Thrown by JAXB : Property "Any" is already defined. Use <jaxb:property> to resolve this conflict. -> [Help 1]

今天用Maven配置wsdl生成Java代码的时候出现了这个错误,找到一个解决方法,分享给大家

参考自

http://stackoverflow.com/questions/13499860/jax-ws-error-on-wsdl-file-error-resolving-component-sschema


需要配置一个xsd.xjb 到src/jaxws目录下


<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
          version="2.0">

  <globalBindings>
    <xjc:simple />
  </globalBindings>

  <bindings scd="~xsd:complexType">
    <class name="ComplexTypeType"/>
  </bindings>

  <bindings scd="~xsd:simpleType">
    <class name="SimpleTypeType"/>
  </bindings>

  <bindings scd="~xsd:group">
    <class name="GroupType"/>
  </bindings>

  <bindings scd="~xsd:attributeGroup">
    <class name="AttributeGroupType"/>
  </bindings>

  <bindings scd="~xsd:element">
    <class name="ElementType"/>
  </bindings>

  <bindings scd="~xsd:attribute">
    <class name="attributeType"/>
  </bindings>
</bindings>


然后将以下配置加入pom.xml文件中

<plugin>
                <!-- CHANGE: updated groupId and version -->
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <!-- CHANGE: added args tag to bind http://www.w3.org/2001/XMLSchema.xsd -->
                            <args>
                                <arg>-b</arg><arg>http://www.w3.org/2001/XMLSchema.xsd</arg>
                            </args>
                            <wsdlFiles>
                                <wsdlFile>xxx</wsdlFile>
                            </wsdlFiles>
                            <wsdlLocation>E:/xxx.wsdl</wsdlLocation>
                            <staleFile>${project.build.directory}/jaxws/stale/Service.asmx.stale</staleFile>
                            <!-- CHANGE: added bindingFiles tag to bind XJB customization, located at the default binding files directory, MyProject/src/jaxws/xsd.xjb . -->
                            <bindingFiles>
                                <bindingFile>xsd.xjb</bindingFile>
                            </bindingFiles>
                        </configuration>
                        <id>wsimport-generate-egtestreportengine</id>
                        <phase>generate-sources</phase>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>javax.xml</groupId>
                        <artifactId>webservices-api</artifactId>
                        <version>1.4</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
                    <xnocompile>true</xnocompile>
                    <verbose>true</verbose>
                    <extension>true</extension>
                    <catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
                    <target>2.0</target>
                </configuration>
            </plugin>


这样就可以正常生成代码了,生成的路径,可以更改<sourceDestDir>标签内容来指定

<wsdlLocation>就是wsdl的路径


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值