2013-10-01 39 views
1

我正在使用ehcache-spring-annotations來緩存我的應用程序數據。對於這一點,我有如下配置:Ehcache-Spring-Annotations:如何獲取緩存管理器參考?

<bean id="ehCacheManager" 
     class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" > 
     <property name="configLocation" value="classpath:ehcache.xml"/> 
    </bean>  
    <ehcache:annotation-driven cache-manager="ehCacheManager" /> 

我想離開配置豆「ehCacheManager」的「net.sf.ehcache.CacheManager」的參考。因此,我可以使用'CacheManager'直接在緩存中手動執行放置或刪除操作。

什麼辦法讓 'net.sf.ehcache.CacheManager' 的引用了 'org.springframework.cache.ehcache.EhCacheManagerFactoryBean' 的?

回答

2

我用下面的代碼來獲得在我的課,緩存管理器參考:

@Resource 
private CacheManager ehCacheManager;