我收到错误消息:
无法将 xsd:date 转换为 java.lang.String 类型
我正在使用带有 CXF XJC 插件的 binding.xml 文件
XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Date" type="xsd:date"/>
<xsd:element name="Audit">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Creation">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Date"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
绑定.xml
<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<jaxb:bindings>
<jaxb:globalBindings>
<jaxb:javaType name="java.lang.String" xmlType="xsd:date"/>
</jaxb:globalBindings>
</jaxb:bindings>
</jaxb:bindings>
cxf xjc 插件:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<version>3.0.3</version>
<executions>
<execution>
<id>generate-resources</id>
<phase>generate-resources</phase>
<configuration>
<defaultOptions>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/META-INF/binding.xml</bindingFile>
</bindingFiles>
<noAddressBinding>true</noAddressBinding>
</defaultOptions>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<xsdOptions>
<xsdOption>
<xsd>${basedir}/src/main/resources/xsd/Misc.xsd</xsd>
<packagename>com.mycomp.ext.schema</packagename>
<extension>true</extension>
</xsdOption>
</xsdOptions>
</configuration>
<goals>
<goal>xsdtojava</goal>
</goals>
</execution>
</executions>
</plugin>
生成的代码包含 XMLGregorianCalendar 而不是 String
@XmlElement(name = "Date", required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar date;
请问有什么建议吗?