Spring Boot 2.7+ 默认 Lettuce 5.x 不支持 Redis 6.0+ 的 ACL、RESP3 协议和 TLS 1.3,易引发 RedisConnectionException 或命令解析失败;需升级 Lettuce 至 ≥6.0 版本并显式声明依赖。

Spring Boot 2.7+ 默认的 Redis 客户端(Lettuce 5.x)不支持 Redis 6.0+ 的 ACL、RESP3 协议和 TLS 1.3,直接连高版本 Redis 会报 RedisConnectionException 或命令解析失败。
升级 Lettuce 到 6.0+ 并显式声明版本
Lettuce ACL LOAD、HELLO 3 命令、TLS 1.3 握手等。Spring Boot 2.7.x 的 bom 默认锁定了 Lettuce 5.3.x,必须手动覆盖。
- 在
pom.xml中排除 starter 自带的 Lettuce,并显式引入新版:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <exclusions> <exclusion> <groupId>io.lettuce</groupId> <artifactId>lettuce-core</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.lettuce</groupId> <artifactId>lettuce-core</artifactId> <version>6.3.2.RELEASE</version> </dependency> - 不要只升级
spring-boot-starter-data-redis版本——它本身不决定 Lettuce 实际运行版本,真正起作用的是lettuce-core的 jar 包 - 验证是否生效:启动后检查日志中是否出现
Connecting to Redis at ... using protocol RESP3
Redisson 与 Spring Boot 2.7.x 的模块错配问题
直接升级 redisson-spring-boot-starter 到 3.24+ 很可能引发 NoClassDefFoundError: EmptyListConvertor,因为新版 Redisson 默认适配 Spring Data Redis 3.x,而 Spring Boot 2.7.x 绑定的是 Spring Data Redis 2.7.x。
- 错误典型表现:
redisson-spring-boot-starter:3.25.0拉入了redisson-spring-data-32(面向 SB3),但项目实际运行在 SB2.7 上 - 正确做法是「核心库升级 + 适配器降级」:
<dependency> <groupId>org.redisson</groupId> <artifactId>redisson-spring-boot-starter</artifactId> <version>3.24.1</version> <exclusions> <exclusion> <groupId>org.redisson</groupId> <artifactId>redisson-spring-data-32</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.redisson</groupId> <artifactId>redisson-spring-data-27</artifactId> <version>3.24.1</version> </dependency> - 务必确保
redisson核心库、starter、spring-data 模块三者版本号完全一致,否则类加载时仍可能出错
配置项变更导致连接失败的隐藏陷阱
Spring Boot 2.7 引入了更严格的配置绑定校验,spring.redis.lettuce.pool 下某些旧参数(如 max-wait)若未加单位,会静默失效,最终表现为连接池耗尽、超时异常。
- 错误写法:
max-wait: 2000→ Spring Boot 2.7+ 要求带单位,否则忽略该配置 - 正确写法:
max-wait: 2s或max-wait: 2000ms;同理max-idle、min-idle等也需检查是否被新校验逻辑跳过 - 如果使用 Jedis,注意
spring.redis.jedis.pool下的max-wait同样要加单位,且 Jedis 4.x 已废弃maxWaitMillis字段,改用max-wait - 启用调试模式验证配置是否生效:
logging.level.org.springframework.boot.context.properties.bind=DEBUG,搜索日志中是否有Failed to bind或Ignoring unknown property
最易被忽略的是:多个 Redis 相关 starter(如同时引入 spring-boot-starter-data-redis 和 redisson-spring-boot-starter)会共用同一套 spring.redis.* 配置,但底层连接工厂初始化逻辑不同——此时必须明确指定哪个 starter 生效,或通过 @Primary 标记主 Bean,否则运行时行为不可控。


















