복붙노트

[SPRING] Eclipse가`ehcache '와 동작하도록 설정하는 법

SPRING

Eclipse가`ehcache '와 동작하도록 설정하는 법

요약 / 질문

나는 ehcache를 사용하는 프로젝트를 시작했다. 이 프로젝트는 maven이 활성화되어 있고 mvn을 실행하면 cli에서 clean install이 잘 끝납니다.

프로젝트는 또한 NetBeans에서 열 수 있으며 모든 것이 제대로 표시되지만 Eclipse에서 프로젝트를 열면 ehcache와 관련된 일부 오류가 표시됩니다. NetBeans에서 spring-cache.xml은 "Web Pages"폴더 아래에 있습니다. 이로 인해 이클립스 프로젝트는 동적 인 웹 프로젝트로 인식되지 않을 수도 있지만 여기의 지시 사항을 따르십시오 : https://www.mkyong.com/java/how-to-convert-java-project-to-web- project-in-eclipse / 프로젝트가 실제로 동적 웹 모듈, Java 및 JavaScript를 지원하도록 설정되었는지 확인할 수있었습니다.

또한 IntelliJ에서 프로젝트를 열고 spring-cache.xml에 대한 문제도 발견하지 못했습니다.

또한 http://www.ehcache.org/documentation/에서이 버전의 ehcache 관련 문서를 찾지 못했지만 NetBeans, IntelliJ 및 mvn 클린 설치를 통해 일이 제 일식 설정이라고 생각하게되었습니다. 생각?

자세한 내용은:

이클립스에서 볼 수있는 오류는 다음과 같습니다.

Multiple annotations found at this line:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'ehcache:annotation-driven'.
- schema_reference.4: Failed to read schema document 'http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring-1.1.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>.

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'ehcache:config'.

필자의 Maven 종속성은 다음과 같습니다.

<dependency>
    <groupId>com.googlecode.ehcache-spring-annotations</groupId>
    <artifactId>ehcache-spring-annotations</artifactId>
    <version>1.2.0</version>
</dependency>

어떤 것이 일치해야하는지 : https://mvnrepository.com/artifact/com.googlecode.ehcache-spring-annotations/ehcache-spring-annotations/1.2.0

내 spring-cache.xml 파일은 다음과 같다.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
       xsi:schemaLocation="
                http://www.springframework.org/schema/beans 
                http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring 
                http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd">

    <ehcache:annotation-driven />
    <ehcache:config cache-manager="cacheManager">
        <ehcache:evict-expired-elements interval="60" />
    </ehcache:config>
    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation"  value="${ehcache.config.location}"/>
    </bean>

</beans>

해결법

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

    1.현재 버전의 NetBeans 및 IntelliJ는 Eclipse와 같이 내용을 확인하는 데 엄격하지 않습니다. :) 다음은 내가 발견 한 것입니다.

    현재 버전의 NetBeans 및 IntelliJ는 Eclipse와 같이 내용을 확인하는 데 엄격하지 않습니다. :) 다음은 내가 발견 한 것입니다.

    봄에 ehcache에서. Google 코드 xsd 파일을 찾을 수 없습니다. 상위 오류가 xsd가 제공된 URL에서 더 이상 호스팅되지 않는다는 사실과 관련 있다고 알았습니다.

    google을 사용하여 https://raw.githubusercontent.com/agentgt/ehcache-spring-annotations/master/core/src/main/resources/com/googlecode/ehcache/annotations에서 github 버전에 대한 참조를 찾았습니다. /ehcache-spring-1.2.xsd 아래쪽 xsi schemalocation을 위의 URL로 변경하여 이클립스에서 문제를 해결했습니다.

    참조 된 스택 오버플로 질문은 https://code.google.com/archive/p/ehcache-spring-annotations/source/default/source의 Google 코드 아카이브에 대한 링크를 제공합니다.

    zip을 다운로드하면 zip에서 공식 xsd를 찾을 수 있습니다. /schema/ehcache-spring/ehcache-spring-1.2.xsd (ehcache-spring-1.0.xsd 및 ehcache-spring1.1도 있습니다). 다른 사람이 이전 버전과 관련하여 문제가있는 경우 xsd).

    로컬 스키마 파일을 참조하는 방법을 찾았습니다. 로컬 XML 스키마 파일을 올바르게 참조하는 방법은 무엇입니까?

    프로젝트의 상대 경로에서이 프로젝트를 참조하는 방법에 대한 질문을 게시 할 예정입니다. 우리는이 프로젝트에서 창과 Mac 개발자가 모두 있기 때문입니다. 이것이 당신에게 유용하다면, 세부 사항은 여기에있을 것입니다 : 상대 경로로 로컬 XSD 파일을 참조하는 방법

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

    2.문제 요약 :

    문제 요약 :

    xsi-schemaLocation 참조 :

    http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd

    이클립스에서 유효성 검사 문제가 발생합니다. 명령 줄에는 문제가 없습니다.

    심판을 다음으로 대체 :

    https://raw.githubusercontent.com/agentgt/ehcache-spring-annotations/master/core/src/main/resources/com/googlecode/ehcache/annotations/ehcache-spring-1.1.xsd

    이클립스에서 문제를 해결합니다. 그러나 인터넷에 연결되어 있지 않으면 saxparser가 불평 할 것입니다. 프록시 참조를 넣어서 : -Dhttp.proxyHost = [프록시 호스트] -Dhttp.proxyPort = [프록시 포트] -Dhttps.proxyHost = [프록시 호스트] -Dhttps.proxyPort = [프록시 포트] Maven 빌드가 성공합니다 ....

    나는이 행동의 차이점을 조사했다. ehcache-spring-annotation-1.1.2.jar, META-INF / spring.schemas 파일이 존재합니다.

    해당 파일의 내용 : http \ : //ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.0.xsd=com/googlecode/ehcache/annotations/ehcache-spring-1.0.xsd http \ : //ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd=com/googlecode/ehcache/annotations/ehcache-spring-1.1.xsd

    cmdline maven은이 내용을 사용합니다 (그리고 jar 파일에서 xsd를 찾습니다). 일식하지 않습니다.

    해결책 : 일식 환경 설정으로 이동,  XML -> XML 카탈로그를 열고 새 사용자 항목을 추가하십시오.

    위치 : https://raw.githubusercontent.com/agentgt/ehcache-spring-annotations/master/core/src/main/resources/com/googlecode/ehcache/annotations/ehcache-spring-1.1.xsd

    키 유형 : 공개 ID

    키 : http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd

    대체 웹 주소 : https://raw.githubusercontent.com/agentgt/ehcache-spring-annotations/master/core/src/main/resources/com/googlecode/ehcache/annotations/ehcache-spring-1.1.xsd

    스프링 컨텍스트 파일의 재 검증을 통해 이클립스 작업 공간의 문제를 해결했습니다.

    나는 이클립스의 결점이기 때문에이 솔루션을 더 좋아한다. 나는 이클립스 특유의 솔루션으로 해결한다.

  3. from https://stackoverflow.com/questions/45091553/how-to-configure-eclipse-to-work-with-ehcache by cc-by-sa and MIT license