redis报错:Error processing condition on org.springframework.boot.autoconfigure.data.redis.RedisAutoCon

springboot集成reids报如下:

Error processing condition on org.springframework.boot.autoconfigure.data.redis.RedisAutoCon。

这个问题是由于springboot的版本问题。

使用springboot 2.x以上版本的时候,pom.xml文件中

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

应替换为

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

reidsconfig文件中

 @Bean
    public CacheManager cacheManager(RedisTemplate redisTemplate) {
        RedisCacheManager rcm = new RedisCacheManager(redisTemplate);
        return rcm;
    }

应替换为:

  @Bean
    public CacheManager cacheManager(RedisConnectionFactory factory) {
        RedisCacheManager cacheManager = RedisCacheManager.create(factory);
        return cacheManager;
    }

 

至此问题解决。-_-


版权声明:本文为wangmouperson原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。