JAXB 生成 JAXBElement<String> 而不是 String
我正在使用插件从文件生成源。问题是我生成而不是.我已经添加了看起来像这样的文件:Apache CXF
cxf-codegen-plugin
Maven
WSDL
JAXBElement<String>
String
jaxb-bindings.xml
<jaxb:bindings version="2.1"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
<jaxb:globalBindings generateElementProperty="false"/>
</jaxb:bindings>
这应该可以防止生成 。但它不起作用,我仍然生成而不是.JAXB
JAXBElement<String>
JAXBElement<String>
String
我的插件看起来像这样:Maven
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.runtime.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>${cxf.runtime.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-jaxb</id>
<phase>generate-sources</phase>
<configuration>
<additionalJvmArgs>-Dfile.encoding=UTF8</additionalJvmArgs>
<wsdlOptions>
<wsdlOption>
<wsdl>src/main/resources/wsdl/Cubiks.wsdl</wsdl>
<extraargs>
<extraarg>-b</extraarg>
<extraarg>${basedir}/jaxb-bindings.xml</extraarg>
<extraarg>-b</extraarg>
<extraarg>${basedir}/jaxws-bindings.xml</extraarg>
<extraarg>-exsh</extraarg>
<extraarg>true</extraarg>
<extraarg>-wsdlLocation</extraarg>
<extraarg></extraarg>
</extraargs>
</wsdlOption>
<wsdlOption>
<wsdl>src/main/resources/wsdl/CubiksCallBackService.wsdl</wsdl>
<extraargs>
<extraarg>-b</extraarg>
<extraarg>${basedir}/jaxws-bindings.xml</extraarg>
<extraarg>-b</extraarg>
<extraarg>${basedir}/jaxb-bindings.xml</extraarg>
<extraarg>-exsh</extraarg>
<extraarg>true</extraarg>
<extraarg>-p</extraarg>
<extraarg>com.cubiks.ws.callback</extraarg>
<extraarg>-wsdlLocation</extraarg>
<extraarg></extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
CXF
版本是 。有人知道问题出在哪里吗?2.6.0
编辑
XSD非常巨大。这是生成元素JAXBElement<String>
<xs:complexType name="ServiceResponse">
<xs:sequence>
<xs:element minOccurs="0" name="RequestStatus" type="tns:RequestStatus"/>
<xs:element minOccurs="0" name="RequestStatusDescription" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="ServiceResponse" nillable="true" type="tns:ServiceResponse"/>
生成的源是:
@XmlElementRef(name = "RequestStatusDescription", namespace = "http://www.cubiksonline.com/2009/08/AssessmentProvider", type = JAXBElement.class)
protected JAXBElement<String> requestStatusDescription;