当前位置: 代码迷 >> Java Web开发 >> 【100分】【】Spring+ibatis+ehcache MethodCacheInterceptor的invoke方法没有执行
  详细解决方案

【100分】【】Spring+ibatis+ehcache MethodCacheInterceptor的invoke方法没有执行

热度:3556   发布时间:2016-04-10 23:59:36.0
【100分】【在线等】Spring+ibatis+ehcache MethodCacheInterceptor的invoke方法没有执行
小弟最新做一个项目 需要使用到Spring+ibatis+ehcache 参照网上的资料自己写了一些配置 可惜MethodCacheInterceptor的invoke方法始终没有执行。想请各位高人指点迷津

这个是Tomcat启动log信息 其中MethodCacheInterceptor已经被初始化了

2013-10-29 10:17:24,179 INFO [org.springframework.cache.ehcache.EhCacheManagerFactoryBean]  main org.springframework.cache.ehcache.EhCacheManagerFactoryBean.afterPropertiesSet(EhCacheManagerFactoryBean.java:100) - <Initializing EHCache CacheManager>
2013-10-29 10:17:26,693 INFO [net.sf.ehcache.util.UpdateChecker]  net.sf.ehcache.CacheManager@7b7d8769 net.sf.ehcache.util.UpdateChecker.doCheck(UpdateChecker.java:98) - <New update(s) found: 2.6.5 [http://www.terracotta.org/confluence/display/release/Release+Notes+Ehcache+Core+2.6]. Please check http://ehcache.org for the latest version.>
2013-10-29 10:17:30,781 INFO [com.gaotime.datadictionary.utils.MethodCacheInterceptor]  main com.gaotime.datadictionary.utils.MethodCacheInterceptor.afterPropertiesSet(MethodCacheInterceptor.java:30) - <[ name = lowFreCache status = STATUS_ALIVE eternal = false overflowToDisk = true maxEntriesLocalHeap = 100000 maxEntriesLocalDisk = 500000 memoryStoreEvictionPolicy = LFU timeToLiveSeconds = 28800 timeToIdleSeconds = 28800 diskPersistent = false diskExpiryThreadIntervalSeconds = 120 cacheEventListeners: net.sf.ehcache.statistics.LiveCacheStatisticsWrapper  hitCount = 0 memoryStoreHitCount = 0 diskStoreHitCount = 0 missCountNotFound = 0 missCountExpired = 0 maxBytesLocalHeap = 0 overflowToOffHeap = false maxBytesLocalOffHeap = 0 maxBytesLocalDisk = 0 pinned = false ] A cache is required. Use setCache(Cache) to provide one.>


这个是ehcache文件

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" 
updateCheck="true"
monitoring="autodetect">
<diskStore path="java.io.tmpdir/ehcache" /> 
<defaultCache maxElementsInMemory="10000" 
eternal="false" 
timeToIdleSeconds="600" 
timeToLiveSeconds="600" 
overflowToDisk="true" 
diskSpoolBufferSizeMB="30"
maxElementsOnDisk="50000" 
diskPersistent="false" 
diskExpiryThreadIntervalSeconds="120" 
memoryStoreEvictionPolicy="LRU"/>

 <!-- 8小时更新缓存 -->
<cache name="lowFreCache" 
maxElementsInMemory="100000"
maxElementsOnDisk="500000" 
eternal="false" 
overflowToDisk="true"
diskPersistent="false" 
diskSpoolBufferSizeMB="30" 
timeToIdleSeconds="28800" 
timeToLiveSeconds="28800"
memoryStoreEvictionPolicy="LFU" />
</ehcache>  


这个是applicationContext-cache.xml配置ehcache

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache"
    xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"  
xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/cache 
http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
    http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring     
    http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
    
    <!-- cacheManager工厂类,指定ehcache.xml的位置   -->
    <bean id="cacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
        p:configLocation="classpath:/cache/ehcache.xml" p:shared="true"/>
        
     <!--声明cacheManager -->
    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" 
        p:cacheManager-ref="cacheManagerFactory" />     
        
     <!-- 8小时更新缓存 -->
    <bean id="lowFreCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
        <property name="cacheManager" ref="cacheManagerFactory" />
  相关解决方案