Spring Boot2 系列教程(三十)Spring Boot 整合 Ehcache

工程创建完成后,引入 Ehcache 的依赖,Ehcache 目前有两个版本:

Spring Boot2 系列教程(三十)Spring Boot 整合 Ehcache_第1张图片

这里采用第二个,在 pom.xml 文件中,引入 Ehcache 依赖:

org.springframework.boot

spring-boot-starter-cache

org.springframework.boot

spring-boot-starter-web

net.sf.ehcache

ehcache

2.10.6

添加 Ehcache 配置


在 resources 目录下,添加 ehcache 的配置文件 ehcache.xml ,文件内容如下:

maxElementsInMemory=“10000”

eternal=“false”

timeToIdleSeconds=“120”

timeToLiveSeconds=“120”

overflowToDisk=“false”

diskPersistent=“false”

diskExpiryThreadIntervalSeconds=“120”

/>

maxElementsInMemory=“10000”

eternal=“true”

overflowToDisk=“true”

你可能感兴趣的:(程序员,spring,boot,java,spring)