(九)SpringBoot与Redis
2022-07-04 本文已影响0人
丛鹏
1.pom添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
2.properties添加redis配置信息
![](https://img.haomeiwen.com/i7317292/326782344826e4f1.png)
![](https://img.haomeiwen.com/i7317292/48fd9712637f287c.png)
应为redis会设置到存储很多东西,所以我们进行了工具封装
1.创建redis公共类
![](https://img.haomeiwen.com/i7317292/4c3c813de4d07fe6.png)
2.创建一个公共类(object与string的转换)
![](https://img.haomeiwen.com/i7317292/5b88a4532fe5a309.png)
3.测试Redis 是否存储成功
![](https://img.haomeiwen.com/i7317292/621bb0d1d986bfb6.png)