一、添加依赖
在Pom.xml文件添加dependency
<!--redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--lettuce pool缓存连接池-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.6.2</version>
</dependency>
<!--redis-->
二、添加配置
application.properties文件配置redis服务器和连接池
# 配置redis服务器属性
spring.redis.port=6379
spring.redis.host=192.168.200.129
spring.redis.timeout=1000ms
spring.redis.database=0
spring.redis.password=
# 配置redis连接池属性
spring.redis.lettuce.pool.max-active=8
spring.redis.lettuce.pool.max-idle=8
spring.redis.lettuce.pool.min-idle