Java 无法解析符号 xsd 文件

问题描述

我有以下 .xsd 文件

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://soapexercise.plonca.sri.pja.edu/employees"
           targetNameSpace="http://soapexercise.plonca.sri.pja.edu/employees"
           elementFormDefault="qualified">

    <xs:complexType name="employeeDto">
        <xs:sequence>
            <xs:element name="id" type="xs:decimal" minOccurs="0"/>
            <xs:element name="firstName" type="xs:string"/>
            <xs:element name="lastName" type="xs:string"/>
            <xs:element name="birthDate" type="xs:date"/>
            <xs:element name="job" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="getEmployeesResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="employees" type="tns:employeeDto" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>

IntelliJ 表示无法解析 tns:employeeDto。如果我尝试在文件上运行 jaxb2:xjc 插件,我会得到以下堆栈跟踪:https://pastebin.com/CfseWE23。我应该怎么做才能解决 tns:employeeDto

解决方法

targetNameSpace 应该是 targetNamespace。属性大小写错误,无效。

https://www.w3.org/TR/xmlschema-1/#Schema_details