1.问题描述
[collect-stage-parser-slave12] [2022-03-04 08:32:12] org.springframework.dao.QueryTimeoutException: Redis command timed out; nested exception is io.lettuce.core.RedisCommandTimeoutException: Command timed out after 1 minute(s)
[collect-stage-parser-slave12] [2022-03-04 08:32:12] at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:70)
[collect-stage-parser-slave12] [2022-03-04 08:32:12] at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41)
[collect-stage-parser-slave12] [2022-03-04 08:32:12] at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44)
[collect-stage-parser-slave12] [2022-03-04 08:32:12] at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42)
[collect-stage-parser-slave12] [2022-03-04 08:32:12] at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:268)
百度了一些解答,大体是如下原因:
redis:
jedis:
pool:
max-active: 10000
max-wait: 3000
max-idle: 20
host: 10.216.*.*
port: 6379
password: ****
配置文件集成了jedis,但是错误信息依然报的是lettuce的错误,说名jedis没有生效。
发现springBoot在自动注入的时候会优先加载lettuce的连接工厂,这就发现配置中的配置没有发挥作用。
2.解决方法:
这是lettuce的bugspring-boot-starter-data-redis
引用的是lettuce做为redis的连接方式,所以我们需要用别的代替,比如jedis
在pom依赖中排除lettuce
,再引入jedis
<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>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.3.0</version>
</dependency>