我想要我的所有xjc生成的類實現可串行化接口。 在post閱讀解決方案後,我實現了,但下面的錯誤jaxb2-maven-plugin
拋出:如何使用maven jaxb生成類實現可串行化
[ERROR] file: mapping.xsd [17,34] org.xml.sax.SAXParseException; systemId: file:mapping.xsd; lineNumber: 17; columnNumber: 34; src-annotation: elements can only contain and elements, but 'globalBindings' was found. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) at
我的XSD示例:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
attributeFormDefault="unqualified"
elementFormDefault="qualified">
<xs:element name="MappingFile" type="MappingFileType">
<xs:annotation>
<jaxb:globalBindings>
<xjc:serializable uid="43538530765l"/>
</jaxb:globalBindings>
</xs:annotation>
Maven插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<sources>
<source>xxxx/yyy/mapping.xsd</source>
</sources>
<packageName>xx.yy.zz.jaxp</packageName>
</configuration>
</plugin>
是否有我需要的任何依賴用來避免這種異常?請摘錄。