spring-boot-starter-cache
然后创建EhCache的配置文件ehcache.xml。
<?xml version="1.0" encoding="UTF-8"?><ehcache 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:
type: ehcache
ehcache:
config: classpath:/ehcache.xml
这样就可以开始使用Ehcache了,测试代码与Spring Boot