package com.ks.tool.bkz;
|
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import redis.clients.jedis.JedisPool;
|
import redis.clients.jedis.JedisPoolConfig;
|
|
@Configuration
|
public class RedisConfig {
|
@Value("${spring.redis.host}")
|
private String host;
|
|
@Value("${spring.redis.port}")
|
private int port;
|
|
@Value("${spring.redis.timeout}")
|
private int timeout;
|
|
@Value("${spring.redis.jedis.pool.max-idle}")
|
private int maxIdle;
|
|
@Value("${spring.redis.jedis.pool.max-wait}")
|
private long maxWaitMillis;
|
|
@Value("${spring.redis.password}")
|
private String password;
|
|
@Bean
|
public JedisPool redisPoolFactory() throws Exception {
|
System.out.println("JedisPool注入成功!!");
|
System.out.println("redis地址:" + host + ":" + port);
|
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
jedisPoolConfig.setMaxIdle(maxIdle);
|
jedisPoolConfig.setMaxWait(maxWaitMillis);
|
JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password);
|
return jedisPool;
|
}
|
}
|