美文网首页
spring boot实践1----集成 ehcache

spring boot实践1----集成 ehcache

作者: Alice_Lu1 | 来源:发表于2019-05-15 13:20 被阅读0次

前段时间负责把公司用的到mvc 升级成 spring boot,此处来记录下实践中的问题

1.spring boot集成 ehcache

1)添加ehcache缓存文件

2)application.properties配置缓存路径及类型

spring.cache.ehcache.config=classpath:ehcache.xml

spring.cache.type=ehcache

3)启动项目添加@EnableCaching注解 ,引入依赖

<!--开启 cache 缓存-->

<dependency>

    <groupId>net.sf.ehcache</groupId>

    <artifactId>ehcache</artifactId>

</dependency>

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-cache</artifactId>

</dependency>

<!-- ehcache 缓存 -->

4)在需要缓存的地方引用注解,标识出cacheName=users即可

相关文章

网友评论

      本文标题:spring boot实践1----集成 ehcache

      本文链接:https://www.haomeiwen.com/subject/oxlpaqtx.html