【bug记录】使用redis使用时报错org.springframework.data.redis.RedisConnectionFailureException: Unable to connect

【问题描述】

POM引入

【bug记录】使用redis使用时报错org.springframework.data.redis.RedisConnectionFailureException: Unable to connect_第1张图片

其它都是常规的调用,编译也没有报错。但在接口返回报错如下:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Wed Aug 23 14:33:49 CST 2023

There was an unexpected error (type=Internal Server Error, status=500).

Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379

org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379 at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.translateException(LettuceConnectionFactory.java:1689) at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1597) at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1383) at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1366) at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:1093) at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:421) at org.springframework.data.redis.core.RedisConnectionUtils.fetchConnection(RedisConnectionUtils.java:193) at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:144) at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:105) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:209) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:189) at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96) at org.springframework.data.redis.core.DefaultValueOperations.set(DefaultValueOperations.java:256) at com.gbfore.common.redis.RedisCacheService.setCacheObject(RedisCacheService.java:51)

 【问题解决】

在POM中添加commons-pool2引入,错误消失 

【bug记录】使用redis使用时报错org.springframework.data.redis.RedisConnectionFailureException: Unable to connect_第2张图片

对这一点很无语,为什么spring-boot-starter-data-redis包不直接在内部引入,非要单独再引入一边。

 

你可能感兴趣的:(Spring,boot,框架应用,bug,redis,数据库)