2017-10-07 2 views
0

J'essaie actuellement d'implémenter la mise en cache pour mon application et je suis confronté à une erreur de "cvc-complex-type.2.4.c: Le caractère générique correspondant est strict, mais aucune déclaration ne peut être trouvée pour l'élément 'cache: annotation-driven'." dans mon pom.xml. Est-ce que je manque quelque chose ici?cvc-complex-type.2.4.c: Le caractère générique correspondant est strict, mais aucune déclaration ne peut être trouvée pour l'élément 'cache: annotation-driven'

pom.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:context="http://www.springframework.org/schema/context" 
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:cache="http://www.springframework.org/schema/cache" 
xmlns:p="http://www.springframework.org/schema/p" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd 
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd 
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/cache 
        http://www.springframework.org/schema/cache/spring-cache.xsd 
        http://www.springframework.org/schema/tx/spring-tx.xsd"> 

<context:annotation-config /> 
<context:component-scan base-package="packages path" /> 

<!-- Enables the caching through annotations --> 
<cache:annotation-driven /> 

<!-- Generic cache manager based on the JDK ConcurrentMap --> 
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager"> 
    <property name="caches"> 
     <set> 
      <bean 
       class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" 
       p:name="task" /> 
     </set> 
    </property> 
</bean> 

Répondre

0

Votre commande dans l'attribut schemaLocation est faux. Au lieu de

xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans.xsd 
       http://www.springframework.org/schema/context 
       http://www.springframework.org/schema/context/spring-context.xsd 
       http://www.springframework.org/schema/tx 
       http://www.springframework.org/schema/cache 
       http://www.springframework.org/schema/cache/spring-cache.xsd 
       http://www.springframework.org/schema/tx/spring-tx.xsd" 

il devrait être

xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans.xsd 
       http://www.springframework.org/schema/context 
       http://www.springframework.org/schema/context/spring-context.xsd 
       http://www.springframework.org/schema/cache 
       http://www.springframework.org/schema/cache/spring-cache.xsd 
       http://www.springframework.org/schema/tx 
       http://www.springframework.org/schema/tx/spring-tx.xsd" 

Les valeurs schemaLocation se compose toujours des paires d'éléments. Le premier élément dénote l'identifiant du schéma, qui est utilisé dans les attributs xmlns, le second élément de chaque paire dénote l'emplacement du fichier xsd. Dans votre code, vous dites essentiellement à l'analyseur que le fichier xsd de l'identifiant http://www.springframework.org/schema/tx est situé au http://www.springframework.org/schema/cache et le fichier xsd de l'identifiant http://www.springframework.org/schema/cache/spring-cache.xsd est situé au http://www.springframework.org/schema/tx/spring-tx.xsd.

+0

Ah je vois comment ça fonctionne maintenant. Merci pour l'aide :) – Sebastian