mybatis整合ehcache

知识点:mybatis整合encache缓存框架,缓存从数据库中,查询的数据,不使用mybatis自带的二级缓存

补充:github上Mybatis Ehcache 适配器包说明地址:http://www.mybatis.org/ehcache-cache/index.html

(1)向pom.xm中导入缓存依赖包,和适配器包

<!--ehcache依赖-->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>

<!--Mybatis Ehcache 适配器包-->
<dependency>
<groupId>org.mybatis.caches</groupId>
<artifactId>mybatis-ehcache</artifactId>
<version>1.1.0</version>
</dependency>

(2)向mapper.xml中,添加配置
<cache type="org.mybatis.caches.ehcache.EhcacheCache"></cache> //调用Mybatis Ehcache 适配器包中的接口,实现缓存功能
<!--<cache eviction="FIFO" flushInterval="60000" readOnly="false" size="1024"></cache>-->//区别mybatis自带的二级缓存配置
 
 

猜你喜欢

转载自www.cnblogs.com/shuaifing/p/9283750.html