SpringBoot 2.x 之后,默认采用 Lettuce 作为 Redis 的连接客户端。当然,我们依然可以强制切换回熟悉的 Jedis。下面介绍具体的配置步骤。
基本配置
1. 依赖管理
与 Lettuce 不同,使用 Jedis 需要额外引入 Jedis 包及其依赖池。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
</dependencies>
2. 配置文件
Redis 的基础配置大同小异,区别主要在于线程池参数的设置。在 application.yml 中添加如下配置:
spring:
redis:
host: 127.0.0.1
port:


