首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JDK8不使用JDK8 (WS客户端)

JDK8不使用JDK8 (WS客户端)
EN

Stack Overflow用户
提问于 2014-06-30 17:22:05
回答 1查看 2.2K关注 0票数 7

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

我使用的是纯JDK8工具链,这意味着我使用了来自JDK8 dir的wsimport工具。

现在,问题是: JDK8中的wsimport工具生成的JDK8源代码不符合JDK8 Javadoc。正如您可能知道的,Javadoc工具已经变成了在JDK8中更严格

考虑以下简单模式:

代码语言:javascript
复制
<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工具将生成代码如下:

代码语言:javascript
复制
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;必须替换end >以使其在JDK8中正确)。这些无效注释的结果是生成失败。

我知道我可以在JDK8中关闭doclint,但我想知道我是不是做错了什么。它只是纯粹的JDK8工具。没什么花哨的。这些工具应该一起使用,对吧?在甲骨文发布之前,他们已经进行了彻底的测试了吗?所以我假设我做错了什么。比如呢?

谢谢。

复制步骤

链接到WSDL (包括模式)

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

我使用这样的wsimport命令行:

代码语言:javascript
复制
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

代码语言:javascript
复制
"C:\Program Files\Java\jdk1.8.0_05\bin\javadoc" ^
   -sourcepath D:\JavaDevHG\MavenWSClient\target\generated-sources\jaxws-wsimport ^
   -subpackages org

你会看到这样的东西:

代码语言:javascript
复制
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工具还会产生一系列警告。我能忍受这一切。是错误导致构建失败。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-01 10:34:13

我只能证实你的发现。由于复制该程序集所需的设置非常少,并且没有任何松散的结尾,因此到目前为止,唯一合理的结论是,这是与wsimport 8一起打包的OpenJDK工具中的一个bug。这个工具根本没有被更新以反映同一个JDK包的javadoc工具所施加的新限制。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24495579

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档