【问题标题】:Ehcache-Spring-Annotations: How to get cache manager reference?Ehcache-Spring-Annotations:如何获取缓存管理器参考?
【发布时间】:2013-10-01 06:53:30
【问题描述】:

我正在使用 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" />  

我想从配置的 bean 'ehCacheManager' 中获取 'net.sf.ehcache.CacheManager' 的引用。因此,我可以使用“CacheManager”直接在缓存中手动执行放置或删除操作。

有什么方法可以从“org.springframework.cache.ehcache.EhCacheManagerFactoryBean”中获取“net.sf.ehcache.CacheManager”的引用?

【问题讨论】:

    标签: spring ehcache


    【解决方案1】:

    我使用以下代码在我的班级中获取缓存管理器参考:

    @Resource
    private CacheManager ehCacheManager;
    

    【讨论】:

      猜你喜欢
      • 2016-05-05
      • 2018-02-10
      • 1970-01-01
      • 2012-12-12
      • 1970-01-01
      • 1970-01-01
      • 2015-08-23
      • 1970-01-01
      • 2023-04-09
      相关资源
      最近更新 更多