2012-06-11 85 views
8

我測試的春天緩存,這是我的背景文件春季3.1.1和高速緩存配置問題

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:cache="http://www.springframework.org/schema/cache" 
    xsi:schemaLocation= 
    "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 cache-manager="simpleCacheManager"/> 

    <bean id="simpleCacheManager" class="org.springframework.cache.support.SimpleCacheManager"> 
     <property name="caches"> 
      <set> 
       <bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean"> 
        <property name="name" value="alfresco"/> 
       </bean> 
       <bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean"> 
        <property name="name" value="alfresco_article"/> 
       </bean> 
       <bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean"> 
        <property name="name" value="alfresco_action"/> 
       </bean> 
      </set> 
     </property> 
    </bean> 

我添加了所有所需的庫,但是,我不能驗證庫因爲Eclipse還告訴我,缺少AOPAlliance.jar和org.springframework.context-3.1.1.RELEASE.jar。

的錯誤是:在此行

多個批註創立:類org.springframework.cache.concurrent.ConcurrentCacheFactoryBean未找到。

解決轉變爲org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean

但是,調用此情況下,網址:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [configuration-context.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/config/AopNamespaceUtils 
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894) 
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 

root cause 

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [configuration-context.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/config/AopNamespaceUtils 
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412) 

AOP-alliance.jar和org.springframework.aop-3.1.1 .RELEASE.jar都在classpath中。

任何線索?

感謝,
安德烈

回答

20

仔細檢查org.springframework.context-3.1.1.RELEASE.jar確實在類路徑中。 Eclipse驗證和此問題的錯誤點。

更新:我檢查了,你是對的。 ConcurrentCacheFactoryBean似乎從3.1.0.M1開始被刪除,並可能在相同包中被替換爲ConcurrentMapCacheFactoryBean。我還沒有在發行說明中找到任何證據。但是,如果將緩存的bean類名稱更改爲ConcurrentMapCacheFactoryBean,它看起來確實工作正常。

<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"> 
    <property name="name" value="alfresco"/> 
</bean> 

UPDATE2:是的,的確ConcurrentCacheFactoryBean一直renamedConcurrentMapCacheFactoryBean他們只是沒有得到解決更新教程。

+0

雙重驗證:)它是。 –

+0

@AndreaGirardi我更新了我的答案 – maksimov

+0

是的,它工作,但仍然java.lang.ClassNotFoundException:org.springframework.aop.config.AopNamespaceUtils。其他的東西是否有可能改變?該類在類路徑 –