org.springframework.boot
spring-boot-starter-cache
然后创建EhCache的配置文件ehcache.xml。
<?xml version="1.0" encoding="UTF-8"?><ehcache
【一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义】
浏览器打开:qq.cn.hn/FTf 免费领取
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:noNamespaceSchemaLocation=“http://ehcache.org/ehcache.xsd”
updateCheck=“false”>
<defaultCache maxElementsInMemory=“10000” eternal=“false” timeToIdleSeconds=“600”
timeToLiveSeconds=“600” overflowToDisk=“true” />
<cache name=“cache” maxElementsInMemory=“10000” eternal=“false” timeToIdleSeconds=“120”
timeToLiveSeconds=“600” overflowToDisk=“true” />
然后SpringBoot配置文件中,指明缓存类型并声明Ehcache配置文件的位置。
server:
port: 10900
spring:
profiles:
active: dev
cache: