'redis.clients.jedis.JedisPool' that could not be found

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

Description:

Field jedisPool in com.jcn.redis.service.RedisService required a bean of type 'redis.clients.jedis.JedisPool' that could not be found.

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


Action:

Consider defining a bean of type 'redis.clients.jedis.JedisPool' in your configuration.

改成这样:

@Configuration
@Service
public class RedisService extends CachingConfigurerSupport{

    Logger logger = LoggerFactory.getLogger(RedisService.class);

    @Value("${redis.host}")
    private String host;

    @Value("${redis.port}")
    private int port;

    @Value("${redis.timeout}")
    private int timeout;

    @Bean
    public JedisPool redisPoolFactory() {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, null);
        return jedisPool;
    }

配置信息:

#Redis服务器地址
redis.host=localhost
#Redis服务器连接端口
redis.port=6379
#连接超时时间(毫秒)
redis.timeout=10
#Redis服务器连接密码(默认为空)
#redis.password=12345
#最大活动对象数
redis.poolMaxTotal=1000
#连接池中的最大空闲连接
redis.poolMaxIdle=500
#连接池最大阻塞等待时间(使用负值表示没有限制)
redis.poolMaxWait=500
发布了753 篇原创文章 · 获赞 72 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/qq_41723615/article/details/104518613