报错
org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.233.10:6379
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
...
Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.233.10:6379
...
Caused by: io.lettuce.core.RedisCommandTimeoutException: Command timed out after 3 millisecond(s)
1.5.9版本的 spring-boot-starter-data-redis maven依赖是包含jedis的,但到了2.0.0版本,不包含jedis了,需要我们手动另外添加jedis依赖.(参考“深寒丶”的博客SpringBoot自定义配置Redis连接需要注意的地方(结合JedisConnectionFactory源码))
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
我当时出错还有一个非常低级的错误,配置文件没有写spring
redis.host=192.168.233.10
redis.port=6379
redis.timeout=3
redis.password=123456
redis.poolMaxTotal=10
redis.poolMaxIdle=10
redis.poolMaxWait=3
花费了好几天时间,查遍了所有的方法,都没搞定,都快气疯了,最后不经意间发现了问题
最后得到教训,一个穷尽所有方法都没有解决的问题,那就推倒按照靠谱的教程重新做一边,因为大概率是自己粗心不知道在哪里出了错。