2

Spring Modules プロジェクトの宣言型キャッシュを使用しようとしています。

つまり、機能していません。何もキャッシュされていないようです。

これが私の構成です:

<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>

次に、Spring がアプリケーション コンテキストをロードしたときのログを次に示します...

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 のデバッグまでログを記録しました。

4

2 に答える 2

2

フェイルセーフキャッシュが宣言型キャッシュで機能するとは思わないため、構成用に ehcache.xml ファイルを作成する必要があります。ehcache Spring モジュールの XML スキーマと注釈を使用してキャッシングを設定します。明示的な ehcache.xml を使用しても問題が解決しない場合は、あなたの方法に (近い) 方法でそれを行うコードを掘り下げることができます。

于 2009-02-24T20:46:49.467 に答える
1

私は、アノテーションを介して Spring 3 プロジェクトに Ehcache 統合を提供することを目的とした新しいプロジェクトの作成者の 1 人です。

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

ライブラリは、Spring の @Transactional の精神で 2 つのメソッド レベルのアノテーションを提供します。

@キャッシュ可能 @TriggersRemove

Spring アプリケーションで適切に構成されている場合、このプロジェクトは実行時に @Cacheable アノテーション付きメソッドの周囲にキャッシング アスペクトを作成します。

使用法に関するドキュメントは、プロジェクト wiki にあります。

于 2010-05-01T13:36:19.743 に答える