1.pom.xml中添加依赖。spring-boot-starer-cache中已经有了ehcache和cache-api,可以不用再添加。
<!-- 本地缓存依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
</dependency>
-->
2. application.properties文件中添加配置位置。指定使用的cacheManger是jcache。
#-------------------ehcache----------------------
spring.cache.jcache.config=classpath:/config/ehcache.xml
3. 在配置的目录中新建添加ecache.xml文件。更详细的可以参照官方文档
<config xmlns:xsi=&