Error creating bean with name ‘redisTemplate’问题解决

Error creating bean with name 'redisTemplate’问题解决

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘redisTemplate’ defined in class path resource [org/example/redistest/config/RedisConfig.class]: Failed to instantiate [org.springframework.data.redis.core.RedisTemplate]: Factory method ‘redisTemplate’ threw exception with message: com/fasterxml/jackson/databind/jsontype/TypeResolverBuilder

你的报错可能不和我的有些许不同。

这个报错一般是redisTemplateBean没有创建成功,具体问题看报错:

defined in class path resource [org/example/redistest/config/RedisConfig.class]:

RedisConfig是我的配置类,很显然配置类里有实例化的配置功能没有配置成功

解决方法:

详细检查配置的每一个方法,里面的内容是否都导入了正确的jar包(Maven)

        // 设置redis value的序列化器
        redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
        // 设置hash key的序列化器
        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
        // 设置hash value的序列化器
        redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());

我这里是`(new GenericJackson2JsonRedisSerializer());没配正确

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.15.0</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.15.0</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.15.0</version>
</dependency>

导包刷新就好了。

在这里插入图片描述

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值