Consider revisiting the entries above or defining a bean of type 'org.springframework.data.redis……'

Consider revisiting the entries above or defining a bean of type ‘org.springframework.data.redis.connection.RedisConnectionFactory’ in your configuration.

Action:

Consider revisiting the entries above or defining a bean of type ‘org.springframework.data.redis.connection.RedisConnectionFactory’ in your configuration.

  • 问题描述

    使用Spring Boot Redis缓存,项目启动时报错

    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'
    

    控制台提示:

    Action:
    Consider revisiting the entries above or defining a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory' in your configuration.
    
  • 问题解决

    其实就是导入依赖不全,检查pom.xml:

        
            
                org.springframework.boot
                spring-boot-starter
            
    
            
                org.springframework.boot
                spring-boot-starter-test
                test
            
    
            
                org.springframework.boot
                spring-boot-starter-cache
            
    
            
                org.springframework.boot
                spring-boot-starter-web
            
    
            
                com.alibaba
                fastjson
                1.2.47
            
    
            
                org.springframework.data
                spring-data-redis
            
    
            
                redis.clients
                jedis
            
    
            
                io.lettuce
                lettuce-core
            
    
            
                org.springframework.boot
                spring-boot-starter-data-redis
            
    
            
                org.apache.commons
                commons-pool2
            
        
    
    

如上导包之后,问题解决

你可能感兴趣的:(后端,Spring,Boot学习笔记,问题解决)