2009-02-24 57 views
2

我試圖從Spring模塊項目使用聲明緩存。彈簧模塊緩存不工作......默默

它不工作,即。似乎沒有任何東西被緩存。

這裏是我的配置:

<bean id="cacheManager" 
    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> 
</bean> 

<bean id="cacheProviderFacade" 
    class="org.springmodules.cache.provider.ehcache.EhCacheFacade"> 
    <property name="cacheManager" ref="cacheManager" /> 
</bean> 

<bean id="cacheableService" 
    class="org.springmodules.cache.interceptor.proxy.CacheProxyFactoryBean"> 
    <property name="cacheProviderFacade" ref="cacheProviderFacade" /> 
    <property name="cachingModels"> 
     <props> 
      <prop key="get*">cacheName=default</prop> 
     </props> 
    </property> 
    <property name="flushingModels"> 
     <props> 
      <prop key="update*">cacheNames=default</prop> 
     </props> 
    </property> 
    <property name="target" ref="myServiceBean" /> 
</bean> 

然後,這裏是從春天加載了應用程序上下文...

24 Feb 2009 14:26:20,785 INFO org.springframework.cache.ehcache.EhCacheManagerFactoryBean - Initializing EHCache CacheManager 
24 Feb 2009 14:26:20,801 DEBUG net.sf.ehcache.CacheManager - Configuring ehcache from classpath. 
24 Feb 2009 14:26:20,801 WARN net.sf.ehcache.config.ConfigurationFactory - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: zip:C:/bea/weblogic81/server/bin/myserver/.wlnotdelete/extract/myserver_threeoneoneonline_threeoneoneonline/jarfiles/WEB-INF/lib/ehcache-1.3.0.jar!/ehcache-failsafe.xml 
24 Feb 2009 14:26:20,801 DEBUG net.sf.ehcache.config.ConfigurationFactory - Configuring ehcache from URL: zip:C:/bea/weblogic81/server/bin/myserver/.wlnotdelete/extract/myserver_threeoneoneonline_threeoneoneonline/jarfiles/WEB-INF/lib/ehcache-1.3.0.jar!/ehcache-failsafe.xml 
24 Feb 2009 14:26:20,801 DEBUG net.sf.ehcache.config.ConfigurationFactory - Configuring ehcache from InputStream 
24 Feb 2009 14:26:20,816 DEBUG net.sf.ehcache.config.DiskStoreConfiguration - Disk Store Path: C:\DOCUME~1\bpapa\LOCALS~1\Temp\ 
24 Feb 2009 14:26:20,832 DEBUG net.sf.ehcache.config.ConfigurationHelper - No CacheManagerEventListenerFactory class specified. Skipping... 
24 Feb 2009 14:26:20,832 DEBUG net.sf.ehcache.config.ConfigurationHelper - No CachePeerListenerFactoryConfiguration specified. Not configuring a CacheManagerPeerListener. 
24 Feb 2009 14:26:20,847 DEBUG net.sf.ehcache.config.ConfigurationHelper - No CachePeerProviderFactoryConfiguration specified. Not configuring a CacheManagerPeerProvider. 
24 Feb 2009 14:26:20,863 DEBUG net.sf.ehcache.config.ConfigurationHelper - No BootstrapCacheLoaderFactory class specified. Skipping... 

在此之後,我打了一個調用方法的網頁記錄前綴「myServiceBean」bean中的「get」。但是,沒有記錄任何緩存正在進行。我已經將日誌記錄一路調整爲調試springmodules,spring的緩存包和DEBUG ...因爲Spring模塊的例子很少,並且在網絡上很遠,我想知道以前是否有人看到過...

回答

2

您應該爲您的配置創建一個ehcache.xml文件,因爲我不相信失效安全緩存可用於聲明性緩存。我們使用ehcache Spring模塊XML模式和註釋設置緩存。如果使用顯式的ehcache.xml並不能解決您的問題,那麼我可以挖掘一些代碼(靠近)自己的方式。

+0

感謝找到,我想試試,然後再發布更新... – bpapa 2009-02-24 20:47:51

1

我是一個新的項目的意圖通過註解提供了Ehcache集成春季3個項目的作者之一:

http://code.google.com/p/ehcache-spring-annotations/

圖書館在Spring的@Transactional的精神提供了兩種方法級別的註解:

@Cacheable @TriggersRemove

當Spring應用程序適當配置,該項目將創造緩存在你的@Cacheable註解方法的運行時方面。

使用文檔可以在項目wiki