JDK8无法与JDK8(WS客户端)一起使用 [英] JDK8 not working with JDK8 (WS client)

查看:146
本文介绍了JDK8无法与JDK8(WS客户端)一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单(现有)的Web服务,我想生成一个反对使用JDK8的Web服务客户端。

I have a very simple (existing) web service that I would like to generate a web service client against using JDK8.

我正在使用纯JDK8工具链接意义我使用JDK8目录中的wsimport工具。

I'm using a pure JDK8 tool chain meaning I use the wsimport tool from my JDK8 dir.

现在问题:JDK8中wsimport工具生成的Java源代码不符合JDK8 Javadoc。您可能已经知道Javadoc工具已成为在JDK8中严格得多

Now to the problem: The Java source code generated by the wsimport tool in JDK8 is not JDK8 Javadoc compliant. As you may be aware the Javadoc tool has become a lot more strict in JDK8.

考虑以下简单模式:

<xs:schema version="1.0" targetNamespace="http://mavenwsserver.ws.mytest.org/">
  <xs:element name="operation" type="tns:operation"/>
  <xs:element name="operationResponse" type="tns:operationResponse"/>
  <xs:complexType name="operation">
    <xs:sequence>
      <xs:element name="person" type="tns:person" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="person">
    <xs:sequence>
      <xs:element name="firstName" type="xs:string" minOccurs="0"/>
      <xs:element name="lastName" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="operationResponse">
    <xs:sequence>
      <xs:element name="return" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

为此, wsimport 工具将生成Java代码,如下所示:

For this the wsimport tool will generate Java code as follows:

package org.mytest.ws.mavenwsclient;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for person complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="person">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="firstName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="lastName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "person", propOrder = {
    "firstName",
    "lastName"
})
public class Person {

    protected String firstName;
    protected String lastName;

    /**
     * Gets the value of the firstName property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getFirstName() {
        return firstName;
    }

    /**
     * Sets the value of the firstName property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setFirstName(String value) {
        this.firstName = value;
    }

    /**
     * Gets the value of the lastName property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLastName() {
        return lastName;
    }

    /**
     * Sets the value of the lastName property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLastName(String value) {
        this.lastName = value;
    }

}

问题是生成的评论这个班。虽然这种类型的注释将被JDK7中的Javadoc编译器接受,但它不再适用于JDK8。 (结尾>必须替换为& gt; 才能在JDK8中正确)。这些无效注释的结果是构建失败。

The problem is the generated comments for this class. While this type of comments would be accepted by the Javadoc compiler in JDK7 it no longer works in JDK8. (the end > must be replaced by &gt; in order for it to be correct in JDK8). The result of these invalid comments is that the build fails.

我知道我可以关闭JDK8中的doclint 但是我想知道我在这里做错了什么。它只是纯粹的JDK8工具。没有什么花哨。这些工具应该一起工作吗?并且在被Oracle发布之前已经相互彻底测试过?所以我假设我做错了什么。喜欢什么?

I know I can turn off doclint in JDK8 but I wonder if I'm doing something wrong here. It's just pure JDK8 tools. Nothing fancy. These tools are supposed to work together right? and have been thoroughly tested with each other before being released by Oracle? So I'm assuming I'm doing something wrong. Like what?

谢谢。

链接到WSDL (包括架构)

将此文件下载到硬盘上的某个位置。

Download this file to somewhere on your harddrive.

我使用 wsimport 命令行,如下所示:

I use a wsimport command line like this:

mkdir D:\JavaDevHG\MavenWSClient\target\generated-sources\jaxws-wsimport

"C:\Program Files\Java\jdk1.8.0_05\bin\wsimport" -keep ^
  -s D:\JavaDevHG\MavenWSClient\target\generated-sources\jaxws-wsimport ^
  D:/JavaDevHG/MavenWSClient/src/main/wsdl/myWSDL.xml

现在在生成的资源上运行 javadoc

Now run javadoc on the generated sources:

"C:\Program Files\Java\jdk1.8.0_05\bin\javadoc" ^
   -sourcepath D:\JavaDevHG\MavenWSClient\target\generated-sources\jaxws-wsimport ^
   -subpackages org

你会看到这样的东西:

Loading source files for package org.mytest.ws.mavenwsserver...
Constructing Javadoc information...
Standard Doclet version 1.8.0_05
Building tree for all the packages and classes...
Generating .\org\mytest\ws\mavenwsserver\HelloWorldWebService.html...
...
...
Generating .\org\mytest\ws\mavenwsserver\Person.html...
..\..\..\target\generated-sources\jaxws-wsimport\org\mytest\ws\mavenwsserver\Person.java:15: error: bad use of '>'
 * &lt;complexType name="person">
                                ^
..\..\..\target\generated-sources\jaxws-wsimport\org\mytest\ws\mavenwsserver\Person.java:16: error: bad use of '>'
 *   &lt;complexContent>
...
...                       ^

请注意,Javadoc工具也会产生一堆警告。我可以忍受这一点。这是导致构建失败的错误。

Note that Javadoc tool also produces a bunch of WARNINGs. I can live with that. It's the ERRORs that make the build fail.

推荐答案

我只能确认你的发现。由于重现这一点所需的设置很少,没有松散的结果,到目前为止唯一合理的结论是,这是与OpenJDK 8一起打包的 wsimport 工具中的一个错误。该工具尚未更新,以反映同一JDK包的 javadoc 工具所施加的新限制。

I could only confirm your findings. Since the setup required to reproduce this is minimal, with no loose ends, the only reasonable conclusion so far is that this is a bug in the wsimport tool packaged with the OpenJDK 8. This tool has simply not been updated to reflect the new restrictions imposed by the javadoc tool of the same JDK package.

这篇关于JDK8无法与JDK8(WS客户端)一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆