我在pom.xml中使用以下依赖项
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.1.14</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>2.0.2</version>
<scope>compile</scope>
</dependency>
binding.xjb:
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:bindings schemaLocation="../../../../xsd/icmarchitecture/mom/log/RetrieveExecutionInfo.xsd" node="/xs:schema">
<jxb:globalBindings>
<jxb:javaType name="com.pcm.icm.architecture.util.Timestamp" xmlType="icm:Timestamp" printMethod="toXsdString" parseMethod="create"/>
</jxb:globalBindings>
RetrieveExecutionInfo.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by pcm (pcm) -->
<!-- edited with XML Spy v4.4 U (http://www.xmlspy.com) by bbl (bbl) -->
<xs:schema
targetNamespace="http://www.pcm.com/icm/architecture/mom/log/payload"
xmlns="http://www.pcm.com/icm/architecture/mom/log/payload"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://www.pcm.com/icm/architecture/status/payload"
xmlns:icm="http://www.pcm.com/icm/architecture/common/payload"
elementFormDefault="qualified" attributeFormDefault="qualified">
<xs:import
namespace="http://www.pcm.com/icm/architecture/status/payload"
schemaLocation="../../status/status.xsd"/>
<xs:import
namespace="http://www.pcm.com/icm/architecture/common/payload"
schemaLocation="../../common/ICMTypedefinitions.xsd"/>
<xs:complexType name="FilterKeyValueType">
<xs:annotation>
<xs:documentation>Filter on key value pair</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Key" type="xs:string"/>
<xs:element ref="Operator"/>
<xs:element name="Value" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="FilterKey">
<xs:annotation>
<xs:documentation>Filter on Key</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="Operator"/>
<xs:element name="Value" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="KeyValueType">
<xs:annotation>
<xs:documentation>Key value pair</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Key" type="xs:string"/>
<xs:element name="Value" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Operator">
<xs:annotation>
<xs:documentation>Operator for a filter</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="greater_equal"/>
<xs:enumeration value="greater"/>
<xs:enumeration value="less"/>
<xs:enumeration value="less_equal"/>
<xs:enumeration value="not_equal"/>
<xs:enumeration value="equal"/>
<xs:enumeration value="like"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FilterService">
<xs:annotation>
<xs:documentation>Filter on service</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="ServiceAddress"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="FilterTimestamp">
<xs:annotation>
<xs:documentation>Filter on timestamp</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="Operator"/>
<xs:element name="Value" type="icm:Timestamp"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ExecutionInfoElement">
<xs:annotation>
<xs:documentation>Reply element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="ServiceAddress"/>
<xs:element name="RequestTimestamp" type="icm:Timestamp" minOccurs="0"/>
<xs:element name="DurationInMillis" type="xs:long" minOccurs="0"/>
<xs:element name="RequestLogMsgId" type="xs:string" minOccurs="0"/>
<xs:element name="KeyValue" type="KeyValueType" minOccurs="0" maxOccurs="999"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="FilterMillis">
<xs:annotation>
<xs:documentation>Filter on millis</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="Operator"/>
<xs:element name="Value" type="xs:long"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ServiceAddress">
<xs:annotation>
<xs:documentation>Service address</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="service" type="xs:string" minOccurs="0"/>
<xs:element name="protocol" type="xs:string" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="RetrieveExecutionInfoRq">
<xs:annotation>
<xs:documentation>Request to get execution info elements</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="FilterService" minOccurs="0" maxOccurs="999"/>
<xs:element ref="FilterTimestamp" minOccurs="0" maxOccurs="999"/>
<xs:element ref="FilterMillis" minOccurs="0" maxOccurs="999"/>
<xs:element name="AndFilterKeyValue" type="FilterKeyValueType" minOccurs="0" maxOccurs="999"/>
<xs:element name="OrFilterKeyValue" type="FilterKeyValueType" minOccurs="0" maxOccurs="999"/>
<xs:element ref="FilterKey" minOccurs="0" maxOccurs="999"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="RetrieveExecutionInfoRs">
<xs:annotation>
<xs:documentation>Reply with execution info elements</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="statusInfo" type="ns1:statusType"/>
<xs:element ref="ExecutionInfoElement" minOccurs="0" maxOccurs="999"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Maven版本-3.1 Java版本-1.7
错误:
org.xml.sax.SAXParseException; systemId:文件:/ C:/Data/NewGitRepo/TestICMGitRepo/ICMTrunk/icmarchitecture/src/main/resources/xjb/icmarchitecture/mom/log/binding.xjb; lineNumber:7; columnNumber:136; UndeclaredPrefix:无法将“ icm:Timestamp”解析为QName:未声明前缀“ icm”。 在com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) 在com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) 在com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437) 在com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368) 在com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
org.xml.sax.SAXParseException; systemId:文件:/binding.xjb; lineNumber:7; columnNumber:136; cvc-attribute.3:元素'jxb:javaType'上的属性'xmlType'的值'icm:Timestamp'对于类型'QName'无效。 在com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) 在com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) 在com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437) 在com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368) 在com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
使用Java 1.7编译器通过eclipse进行maven全新安装时,出现上述异常
但是如果我将Java编译器更改为1.8,则可以正常工作。但是我想在具有Java 1.7版本的JBoss服务器中部署此jar。
请对此提供帮助。预先感谢。
答案 0 :(得分:0)
您应该在绑定文件中声明您的icm前缀。
将tar
添加到根元素。
这与JAXB无关,而与XML无关。 JAXB期望一个“限定名称”为z
。 “合格名称”表示必须定义前缀并指向正确的名称空间。