Spring 3.1 Кеш проблема пространства имен - PullRequest
3 голосов
/ 13 мая 2011

Я пытаюсь использовать конфигурацию и пространства имен Spring 3.1 согласно spring doc .я также скачал последнюю версию jar с сайта Spring, но все еще у меня возникает эта проблема с пространствами имен

Unable to locate Spring NamespaceHandler for element 'cache:annotation-driven' of schema namespace 'http://www.springframework.org/

схема / кэш '

файл конфигурации Spring

<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" 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-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">


cache:annotation-driven />

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache"/>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" 
    p:config-location="classpath:ehcache.xml"/>

Ответы [ 2 ]

6 голосов
/ 13 мая 2011

вам нужно spring-context-support.jar и spring-context.jar на пути к классам.

spring-context имеет класс CacheNamespaceHandler.

(обратите внимание, что Spring теперь использует другую схему именования дляих банки, но context и context support сохраняются в именах)

3 голосов
/ 09 февраля 2012

Для пользователей Maven добавьте следующую зависимость:

    <spring-version>3.1.0.RELEASE</spring-version>
    <ehcache-version>2.4.2</ehcache-version>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${spring-version}</version>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-core</artifactId>
        <version>${ehcache-version}</version>
    </dependency>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...