正文
这次写一下springboot与redis的结合,这里使用的是redis集群模式(主从),主从环境的搭建,请参考redis集群搭建
搭建完redis集群环境后,开始springboot之旅
1、REDIS介绍
redis的介绍及应用场景参考 redis介绍
2、项目构建
我们还是从redis项目构建开始说起,首先还是进入的spring官网,
从这里开始构建项目,如下图
![](https://img-blog.csdnimg.cn/img_convert/809b25c458cba86c6651a78e1dd42798.png)
当然也可以自己添加pom文件,如下
![](https://img-blog.csdnimg.cn/img_convert/bcbbe0e694327a3f3dd879a7937e41b2.png)
3、添加配置文件
application.properties中
![](https://img-blog.csdnimg.cn/img_convert/78a4d20e9404c390d00f75f40648b666.png)
4、JEDIS配置类的编写
这里是核心jedisCluster这个bean的创建
![](https://img-blog.csdnimg.cn/img_convert/bd2c08dc7406df09361d8d45351fda01.png)
![](https://img-blog.csdnimg.cn/img_convert/0ea98ac59fe0fca8a7272d987df1451c.png)
![]()