《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!
工程创建完成后,引入 Ehcache 的依赖,Ehcache 目前有两个版本:
这里采用第二个,在 pom.xml 文件中,引入 Ehcache 依赖:
org.springframework.boot
spring-boot-starter-cache
org.springframework.boot
spring-boot-starter-web
net.sf.ehcache
ehcache
2.10.6
在 resources 目录下,添加 ehcache 的配置文件 ehcache.xml ,文件内容如下:
<defaultCache
maxElementsInMemory=“10000”
eternal=“false”
timeToIdleSeconds=“120”
timeToLiveSeconds