복붙노트

[SPRING] Spring과 함께 EhCache를 위해 로컬 xsd를 사용하는 방법

SPRING

Spring과 함께 EhCache를 위해 로컬 xsd를 사용하는 방법

우리는 ehCache와 Spring에 대해 ehcache.xml의 XSD 파일을 http://ehcache.org/ehcache.xsd로 지정할 때 문제가 발생했습니다. 모든 것이 정상입니다. 애플리케이션이 올바르게 시작할 수 있습니다.     그러나 우리 서버는 외부 웹 사이트에 접근 할 수 없으므로 다음과 같이 XSD 위치를 로컬로 변경했습니다. 그러나 응용 프로그램은 다음 예외 (이미 ehcache.xml과 같은 ehcache.xsd를 클래스 폴더에 복사)로 시작할 수 없습니다.     나는 많은 해결책을 봤지만 여전히 수정할 수는 없다. 이것에 대해 당신의 도움이 필요합니다. 고맙습니다.

봄 : 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

해결법

  1. ==============================

    1.ehcache.xsd를 다운로드하여 config xml 파일과 같은 폴더에 저장하십시오. 아래처럼 XML 헤더를 수정하면 클래스 경로 접두어를 알 수 있습니다.

    ehcache.xsd를 다운로드하여 config xml 파일과 같은 폴더에 저장하십시오. 아래처럼 XML 헤더를 수정하면 클래스 경로 접두어를 알 수 있습니다.

    <ehcache
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="classpath:ehcache.xsd">
    

    이것은 개발 및 생산 환경에서 작동합니다.

  2. ==============================

    2.일반적으로 xsi : noNamespaceSchemaLocation = "http://ehcache.org/ehcache.xsd"로 설정했지만 오프라인 환경에서는 작동하지 않습니다.

    일반적으로 xsi : noNamespaceSchemaLocation = "http://ehcache.org/ehcache.xsd"로 설정했지만 오프라인 환경에서는 작동하지 않습니다.

  3. ==============================

    3.내 해결 방법은이 xsd 파일을 절대 경로 (예 : c : /ehcache.xsd)에 추가하고 ehcache.xml에서이 위치를 가리 킵니다. 희망이 동일한 문제에 직면하는 사람을 도울 것입니다.

    내 해결 방법은이 xsd 파일을 절대 경로 (예 : c : /ehcache.xsd)에 추가하고 ehcache.xml에서이 위치를 가리 킵니다. 희망이 동일한 문제에 직면하는 사람을 도울 것입니다.

    아직도 다른 해결책을 찾으려고 고대하고 있습니다.

    감사.

  4. from https://stackoverflow.com/questions/13266339/how-to-use-local-xsd-for-ehcache-with-spring by cc-by-sa and MIT license