您好,欢迎来到年旅网。
搜索
您的当前位置:首页No beans of ‘RedisConnectionFactory‘ type found.解决方案

No beans of ‘RedisConnectionFactory‘ type found.解决方案

来源:年旅网

出现这个问题,定义redis用到的redisTemplate对象序列化,

我们需要写一个配置类

@Configuration
public class RedisConfig {
    @Bean
    public RedisTemplate<String, Serializable> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, Serializable> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        redisTemplate.setKeySerializer(RedisSerializer.string());
        redisTemplate.setValueSerializer(RedisSerializer.json());
        return redisTemplate;
    }
}

写完之后redisConnectionFactory下面会出现红线,

解决方案:

修改redis的依赖版本号,应该是不兼容的问题,修改版本号多搞一个版本一般都行,这种Template结尾的都是修改版本号

  <!--redis-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <version>2.5.9</version>
        </dependency>

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- oldu.cn 版权所有 浙ICP备2024123271号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务