pet*_*erh 7 java web-services wsimport java-8
我有一个非常简单(现有)的Web服务,我想生成一个反对使用JDK8的Web服务客户端.
我正在使用纯JDK8工具链,这意味着我使用了JDK8目录中的wsimport工具.
现在来看问题:JDK8中wsimport工具生成的Java源代码不符合JDK8 Javadoc.您可能知道Javadoc工具在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>
Run Code Online (Sandbox Code Playgroud)
为此,wsimport工具将生成Java代码,如下所示:
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>
* <complexType name="person">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="firstName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="lastName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </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;
}
}
Run Code Online (Sandbox Code Playgroud)
问题是为此类生成的注释.虽然这种类型的注释将被JDK7中的Javadoc编译器接受,但它不再适用于JDK8.(必须替换end> >以便在JDK8中正确).这些无效注释的结果是构建失败.
我知道我可以在JDK8中关闭doclint,但我想知道我在这里做错了什么.它只是纯粹的JDK8工具.没有什么花哨.这些工具应该一起工作吗?并且在被Oracle发布之前已经相互彻底测试过?所以我假设我做错了什么.像什么?
谢谢.
链接到WSDL (包括模式)
将此文件下载到硬盘上的某个位置.
我使用这样的wsimport命令行:
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
Run Code Online (Sandbox Code Playgroud)
现在运行javadoc生成的源:
"C:\Program Files\Java\jdk1.8.0_05\bin\javadoc" ^
-sourcepath D:\JavaDevHG\MavenWSClient\target\generated-sources\jaxws-wsimport ^
-subpackages org
Run Code Online (Sandbox Code Playgroud)
你会看到这样的事情:
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 '>'
* <complexType name="person">
^
..\..\..\target\generated-sources\jaxws-wsimport\org\mytest\ws\mavenwsserver\Person.java:16: error: bad use of '>'
* <complexContent>
...
... ^
Run Code Online (Sandbox Code Playgroud)
请注意,Javadoc工具也会产生一堆警告.我可以忍受这一点.这是使构建失败的错误.
我只能证实你的发现。由于重现此问题所需的设置非常少,没有任何遗留问题,因此迄今为止唯一合理的结论是,这是wsimport与 OpenJDK 8 一起打包的工具中的一个错误。该工具根本没有进行更新以反映 OpenJDK 8 施加的新限制。javadoc同一个JDK包的工具。
| 归档时间: |
|
| 查看次数: |
1808 次 |
| 最近记录: |