Résumé/QuestionComment configurer Eclipse pour travailler avec `ehcache`
J'ai roulé sur un projet qui utilise ehcache
. Le projet est maven activé et quand je cours mvn clean install
de cli tout se termine bien.
Le projet peut également être ouvert dans NetBeans et tout s'affiche correctement, cependant lorsque j'ouvre le projet dans Eclipse, je vois des erreurs liées à ehcache
. Dans NetBeans, le fichier spring-cache.xml se trouve dans un dossier "Pages Web". Cela m'a fait penser que le projet eclipse peut ne pas être reconnu comme un projet web dynamique, cependant en suivant les instructions ici: https://www.mkyong.com/java/how-to-convert-java-project-to-web-project-in-eclipse/ J'ai pu vérifier que le projet est bien configuré pour supporter Dynamic Web Module, Java et JavaScript.
J'ai également ouvert le projet dans IntelliJ et je n'ai vu aucun problème avec spring-cache.xml.
Je n'ai pas non plus trouvé de documentation liée à cette version de ehcache sur http://www.ehcache.org/documentation/ mais le fait que les choses fonctionnent dans NetBeans, IntelliJ et via mvn clean install
me fait penser à ma configuration eclipse. Pensées?
Plus de détails:
Les erreurs que je vois dans Eclipse sont:
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>.
Et
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'ehcache:config'.
Ma dépendance Maven ressemble à:
<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
<version>1.2.0</version>
</dependency>
qui correspond à ce qu'elle devrait être, sur la base: https://mvnrepository.com/artifact/com.googlecode.ehcache-spring-annotations/ehcache-spring-annotations/1.2.0
Mon fichier printemps-cache.xml ressemble:
<?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>