Summary/Question
I've rolled onto a project that uses ehcache
. The project is maven enabled and when I run mvn clean install
from cli all ends well.
The project can also be opened in NetBeans and everything displays properly, however when I open the project in eclipse, I'm seeing some errors related to ehcache
. In NetBeans the spring-cache.xml is located under a "Web Pages" folder. This made me think that the eclipse project may not be recognized as a dynamic web project, however following the directions here: https://www.mkyong.com/java/how-to-convert-java-project-to-web-project-in-eclipse/ I was able to verify that the project is indeed setup to support Dynamic Web Module, Java and JavaScript.
I also opened the project in IntelliJ and also did not see any issues with the spring-cache.xml.
I also didn't find documentation related to this version of ehcache on http://www.ehcache.org/documentation/ but the fact that things work in NetBeans, IntelliJ and via mvn clean install
make me think its my eclipse setup. Thoughts?
More Details:
The errors I see in eclipse are:
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>.
And
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'ehcache:config'.
My maven dependency looks like:
<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
<version>1.2.0</version>
</dependency>
Which matches what it should be, based on: https://mvnrepository.com/artifact/com.googlecode.ehcache-spring-annotations/ehcache-spring-annotations/1.2.0
My spring-cache.xml file looks like:
<?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>