我们面临一个关于 EhCache 和 Spring 的问题,当我们将 ehcache.xml 中的 XSD 文件指向 http://ehcache.org/ehcache.xsd时,一切正常,我们的应用程序可以正确启动。但是我们的服务器无法访问外部网站,所以我们将 XSD 位置更改为本地,如下所示,但应用程序无法启动并出现以下异常(已将 ehcache.xsd 复制到 classes 文件夹,与 ehcache.xml 相同)。我用谷歌搜索了很多解决方案,但仍然无法修复。我需要你的帮助。非常感谢。
春天:3.1.0 EhCache:2.4.2 服务器:Tomcat 6.0 Java:1.6
配置:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="false" monitoring="autodetect" dynamicConfig="true">
例外:
2012-11-07 16:54:42,003 WARN [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Ignored XML validation warning>
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'ehcache.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:96)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:380)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2440)
... more
2012-11-07 16:54:42,007 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 3 in XML document from ServletContext resource [/WEB-INF/classes/META-INF/ehcache.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ehcache'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
... more
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ehcache'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
... more