无法加载获取错误架构abc.xsd。IllegalArgumentException:资源路径def.xsd已规范化为无效的null
我使用无法加载获取错误架构abc.xsd。IllegalArgumentException:资源路径def.xsd已规范化为无效的null,xsd,java-8,spring-ws,spring-4,Xsd,Java 8,Spring Ws,Spring 4,我使用jaxb2maven插件从xsd生成java类。课程正在生成。下面是我的一个xsd文件的示例 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com" xmlns="http://customer.serviceo
jaxb2maven插件从xsd生成java类。课程正在生成。下面是我的一个xsd文件的示例
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
xmlns="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
xmlns:cust="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com"
xmlns:tr="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/TransactionResultType.xsd"/>
<xsd:import namespace="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/Customer.xsd"/>
<xsd:element name="AddCustomerRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Customers" type="cust:Customers" minOccurs="1" maxOccurs="1" nillable="false" />
</xsd:sequence>
<xsd:attribute name="key" type="xsd:string" use="required" />
<xsd:attribute name="ResellerId" type="xsd:nonNegativeInteger" use="required" />
</xsd:complexType>
</xsd:element>
<xsd:element name="AddCustomerResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RegisterCustomers" type="cust:RegisterCustomers" minOccurs="0" maxOccurs="1" nillable="false" />
</xsd:sequence>
<xsd:attribute name="transactionResult" type="tr:TransactionResultType" use="required"/>
<xsd:attribute name="transactionResultMessage" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
在myCustomerServiceOperations.xsd中,我使用了以下行
<xsd:import namespace="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/TransactionResultType.xsd"/>
现在schemaLocation=“../types/TransactionResultType.xsd”
正在产生问题。虽然它是正确的,因为如果我单击。/types/TransactionResultType.xsd
,它将打开正确的文件。现在spring在路径前面追加了/
,类似于[/../types/TransactionResultType.xsd]
。我如何解决这个问题
谢谢将uriResolver
设置为defaultURIResolver
commonxsdschemacollection集合=新的commonxsdschemacollection(模式);
setUriResolver(新的DefaultURIResolver());
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lmsApiSchema' defined in ServletContext resource [/WEB-INF/spring/appServlet/webservices-context.xml]: Invocation of init method failed; nested exception is org.springframework.xml.xsd.commons.CommonsXsdSchemaException: Schema [ServletContext resource [/schemas/lmsapi/serviceoperations/CustomerServiceOperations.xsd]] could not be loaded; nested exception is java.lang.IllegalArgumentException: The resource path [/../types/TransactionResultType.xsd] has been normalized to [null] which is not valid
....
Caused by: org.springframework.xml.xsd.commons.CommonsXsdSchemaException: Schema [ServletContext resource [/schemas/lmsapi/serviceoperations/CustomerServiceOperations.xsd]] could not be loaded; nested exception is java.lang.IllegalArgumentException: The resource path [/../types/TransactionResultType.xsd] has been normalized to [null] which is not valid
...
Caused by: java.lang.IllegalArgumentException: The resource path [/../types/TransactionResultType.xsd] has been normalized to [null] which is not valid
<xsd:import namespace="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/TransactionResultType.xsd"/>