一、EhCache使用演示
EhCache是一个纯Java的进程内缓存框架,具有快速、精干等特点,Hibernate中的默认Cache就是使用的EhCache。
本章节示例是在Spring Boot集成Spring Cache的源码基础上进行改造。源码地址:https://github.com/imyanger/springboot-project/tree/master/p20-springboot-cache
使用EhCache作为缓存,我们先引入相关依赖。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId></dependency><!--ehcache依赖--><dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache</artifactId></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId></dependency>然后创建EhCache的配置文件ehcache.xml。
<?xml version="1.0" encoding="UTF-8"?><ehcache xmlns:xsi="http:///imyanger/springboot-project/tree/master/p22-springboot-cache-ehcache以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。