我有一个非常简单的 xsd,它定义了一个元素“缓存”
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns="http://mysite/schema/cache"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://mysite/schema/cache">
<xsd:complexType name="objectType" abstract="false">
<xsd:attribute name="target" type="xsd:string">
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="cacheType">
<xsd:sequence>
<xsd:element name="object" type="xsd:string" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="cache" type="cacheType"></xsd:element>
</xsd:schema>
我有一个弹簧配置文件:
<?xml version="1.0" encoding="utf-8"?>
<objects xmlns="http://www.springframework.net"
xmlns:cache="http://mysite/schema/cache"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mysite/schema/cache http://mysite/cache.xsd">
<description>
</description>
<cache:cache>
<cache:object target="site"/>
</cache:cache>
</objects>
在通话期间
Spring.Objects.Factory.Xml.XmlObjectDefinitionReader.DoLoadObjectDefinitions at startup, I get the following error:
[XmlSchemaValidationException: The 'http://mysite/schema/cache:cache' element is not declared.]
这表明 spring 找不到我的架构,但 xsd 可用。
任何想法为什么这不起作用?