写在前面:
继续记录自己的SpringBoot学习之旅,这次是SpringBoot应用相关知识学习记录。若看不懂则建议先看前几篇博客,详细代码可在我的Gitee仓库SpringBoot克隆下载学习使用!
![![[Pasted image 20220903171625.png]]](https://1000bd.com/contentImg/2024/04/20/cad5c01240a9b2a6.png)
![![[Pasted image 20220903171639.png]]](https://1000bd.com/contentImg/2024/04/20/3463792bbba97573.png)
![![[Pasted image 20220903171716.png]]](https://1000bd.com/contentImg/2024/04/20/3a177212348ef9bb.png)
![![[Pasted image 20220904141629.png]]](https://1000bd.com/contentImg/2024/04/20/421c804eb6823bdf.png)
![![[Pasted image 20220904141751.png]]](https://1000bd.com/contentImg/2024/04/20/71c8841044eb9123.png)
![![[Pasted image 20220904141819.png]]](https://1000bd.com/contentImg/2024/04/20/dcc08c6ac41829d4.png)
![![[Pasted image 20220904141901.png]]](https://1000bd.com/contentImg/2024/04/20/67c37336c4170b3e.png)
![![[Pasted image 20220904141947.png]]](https://1000bd.com/contentImg/2024/04/20/eb7b7ff447f813f5.png)
![![[Pasted image 20220904142038.png]]](https://1000bd.com/contentImg/2024/04/20/63faf6dd798e1bd0.png)
注:在上文项目里更改
<dependency>
<groupId>net.sf.ehcachegroupId>
<artifactId>ehcacheartifactId>
dependency>
# 配置cache使用技术
spring:
cache:
type: ehcache
ehcache:
config:ehcache.xml
ehcache.xml文件内容如下:
<ehcache xmlns="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false">
<defaultCache
eternal="false"
diskPersistent="false"
maxElementsInMemory="1000"
overflowToDisk="false"
timeToIdleSeconds="60"
timeToLiveSeconds="60"
memoryStoreEvictionPolicy="LRU"/>
<cache name="SMSCode"
eternal="false"
diskPersistent="false"
maxElementsInMemory="1000"
overflowToDisk="false"
timeToIdleSeconds="60"
timeToLiveSeconds="60"
memoryStoreEvictionPolicy="LRU"/>
ehcache>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-data-redisartifactId>
dependency>
spring:
# 使用redis缓存技术
cache:
type: redis
redis:
use-key-prefix: true
key-prefix: cache_
time-to-live: 5s
redis:
host: localhost
port: 6379
注:其它类似上文