我正在尝试为不同的 xsd 文件分配不同的名称空间,并使用 jaxb2-maven 插件来构建这些 xsd 文件定义的工件。
Maven 无法生成源代码并出现以下错误:The namespace of element 'bindings' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'
这是我的配置:
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb
http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
version="2.1">
<jaxb:bindings schemaLocation="xsd/TheRequest.xsd" node="/xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.package.request" />
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="xsd/TheResponse.xsd" node="/xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.package.response" />
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://company.services.com"
xmlns:tns="http://company.services.com"
elementFormDefault="unqualified">
<xsd:complexType name="FindSomething">
<xsd:sequence>
<xsd:element name="TestMode" type="xsd:string" maxOccurs="1" minOccurs="0"/>
<xsd:element name="Channel" type="xsd:string" maxOccurs="1" minOccurs="1"/>
<xsd:element name="UserId" type="xsd:string" maxOccurs="1" minOccurs="1"/>
<xsd:element name="Role" type="xsd:string" maxOccurs="1" minOccurs="0"/>
<xsd:element name="Format" type="xsd:string" maxOccurs="1" minOccurs="0"/>
<xsd:element name="OrgId" type="xsd:string" maxOccurs="1" minOccurs="1"/>
<xsd:element name="TransactionId" type="xsd:string" maxOccurs="1" minOccurs="1"/>
<xsd:element name="Timeout" type="xsd:long" maxOccurs="1" minOccurs="0"/>
<xsd:element name="RequestSegments" type="tns:RequestSegments" maxOccurs="1" minOccurs="0"/>
<xsd:element name="VerifyUserType" type="xsd:string" maxOccurs="1" minOccurs="0"/>
<xsd:element name="VerifyUserAccess" type="xsd:string" maxOccurs="1" minOccurs="0"/>
<xsd:element name="IncludeFamily" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="AsOfDate" type="xsd:string" maxOccurs="1" minOccurs="0"/>
<xsd:element name="ActiveOnly" type="xsd:string" maxOccurs="1" minOccurs="0"/>
<xsd:element name="SearchType" type="xsd:string" maxOccurs="1" minOccurs="0"/>
<xsd:element name="SearchCriteria" type="tns:SearchCriteria" maxOccurs="1" minOccurs="0"/>
<xsd:element name="AccessPrivileges" type="tns:AccessPrivileges" maxOccurs="1" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType></xsd:schema>
我尝试过使用不同形式的 XML 命名空间指令。在 Eclipse 代码完成中,我可以将绑定 XML 模式视为一个选项,因此我不知道为什么 maven 返回此错误。