【发布时间】:2017-12-18 21:08:48
【问题描述】:
总结/问题
我参与了一个使用ehcache 的项目。该项目已启用 maven,当我从 cli 运行 mvn clean install 时,一切都很好。
该项目也可以在 NetBeans 中打开,并且一切正常显示,但是当我在 eclipse 中打开该项目时,我看到一些与 ehcache 相关的错误。在 NetBeans 中,spring-cache.xml 位于“Web Pages”文件夹下。这让我觉得 eclipse 项目可能不被识别为动态 Web 项目,但是按照这里的指示:https://www.mkyong.com/java/how-to-convert-java-project-to-web-project-in-eclipse/ 我能够验证该项目确实设置为支持动态 Web 模块、Java 和 JavaScript。
我还在 IntelliJ 中打开了该项目,也没有发现 spring-cache.xml 有任何问题。
我也没有在http://www.ehcache.org/documentation/ 上找到与此版本的 ehcache 相关的文档,但是在 NetBeans、IntelliJ 和通过mvn clean install 中工作的事实让我认为这是我的 Eclipse 设置。想法?
更多详情:
我在eclipse中看到的错误是:
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>
【问题讨论】:
标签: spring eclipse maven ehcache