用Redis的时候出现的问题

问题一:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method redisTemplate in org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration required a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)

The following candidates were found but could not be injected:
    - Bean method 'redisConnectionFactory' in 'JedisConnectionConfiguration' not loaded because @ConditionalOnClass did not find required classes 'org.apache.commons.pool2.impl.GenericObjectPool', 'redis.clients.jedis.Jedis'
    - Bean method 'redisConnectionFactory' in 'LettuceConnectionConfiguration' not loaded because @ConditionalOnClass did not find required class 'io.lettuce.core.RedisClient'

具体见图:


image.png

这个是在使用redis的时候依赖添加错误了

错误的依赖

<dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
            <version>2.1.3.RELEASE</version>
        </dependency>

正确的依赖

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-redis</artifactId>
            <version>1.4.0.RELEASE</version>
        </dependency>

问题二:

2020-02-06 18:45:36.823 ERROR 10940 --- [nio-8012-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [com.redisdemo.demo.entity.User]] with root cause

java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [com.redisdemo.demo.entity.User]
image.png

工具类SerializeUtil序列化时无法识别User对象,修改User类实现Serializable接口(public class User implements Serializable),问题解决。如下图:


image.png

问题三:

2020-02-06 20:54:38.762 ERROR 11828 --- [nio-8012-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool] with root cause

redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set
image.png

问题看起来很清楚,这句:ERR Client sent AUTH, but no password is set,它的意思就是redis服务器没设置密码,这里还设置了password,而且即使是空“”也不行。把整个password去掉,重启就可以啦

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1 Redis介绍1.1 什么是NoSql为了解决高并发、高可扩展、高可用、大数据存储问题而产生的数据库解决方...
    克鲁德李阅读 5,660评论 0 36
  • NOSQL类型简介键值对:会使用到一个哈希表,表中有一个特定的键和一个指针指向特定的数据,如redis,volde...
    MicoCube阅读 4,141评论 2 27
  • RedisRedis命令参考网址:http://doc.redisfans.com/ Redis 简介Redis ...
    野柳阅读 1,221评论 0 9
  • 2018.7.21星期六天气晴 亲子日记第137天 《父母规》第111天 姐姐今天参加了青春志愿行——温暖火...
    爱腾睿阅读 341评论 3 7
  • 致女神 我这个装满你的头因你回, 我这个不由己的身随你转, 我这颗不安分的心为你动; 你不经意间看我的那一眼, 其...
    補缺楼丨胡德棒阅读 333评论 0 2

友情链接更多精彩内容