Mybatis整合ehcache
EhCache 是一个分布式缓存框架。
EhCache 是一个纯Java的进程内缓存框架,是一种广泛使用的开源Java分布式缓存,具有快速、精干等特点,是Hibernate中默认的CacheProvider。
在Mybatis二级缓存的基础上整合
配置ehcache
1.下载jar包地址:https://github.com/mybatis/ehcache-cache/releases/tag/mybatis-ehcache-1.0.3
或者 maven配置:
<dependency>
<groupId>org.mybatis.caches</groupId>
<artifactId>mybatis-ehcache</artifactId>
<version>1.0.3</version>
</dependency>
2.引入缓存配置文件ehcache.xml:
3.mapper.xml中使用自定义缓存
4.测试:
结果: