1:maven:
<!-- https://mvnrepository.com/artifact/net.sf.ehcache/ehcache-core -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.11</version>
</dependency>
<dependency>
<groupId>org.mybatis.caches</groupId>
<artifactId>mybatis-ehcache</artifactId>
<version>1.1.0</version>
</dependency>
2:在基础数据的xml文件中加入配置:
<!--添加缓存配置-->
<cache type="org.mybatis.caches.ehcache.EhcacheCache">
<property name="timeToIdleSeconds" value="60"></property><!--<!–当缓存闲置60秒后销毁–>-->
<property name="timeToLiveSeconds" value="160"></property><!--<!–缓存存在160秒后销毁–>-->
<property name="maxEntriesLocalHeap" value="1000"></property>
<property name="maxEntriesLocalDisk" value="10000000"></property>
<property name="memoryStoreEvictionPolicy" value="LRU"></property>
</cache>