报错如下: [Spring session redis executor thread: 1] ERROR org.springframework.data.redis.listener.RedisMessageListenerContainer - Connection failure occurred.
@Configuration
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 36000)
public class RedisConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private int port;
@Value("${spring.redis.password}")
private String password;
@Bean
public JedisPool jedisPool(JedisPoolConfig jedisPoolConfig){
System.out.println("redis相关信息"+host+port);
JedisPool jedisPool = new JedisPool(jedisPoolConfig,host,port,5000,password);
return jedisPool;
}
@Bean
public JedisPoolConfig jedisPoolConfig(){
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMinIdle(10);
jedisPoolConfig.setMaxIdle(100);
jedisPoolConfig.setMaxTotal(1000);
return jedisPoolConfig;
}
/**
* 解决redis集群环境没有开启Keyspace notifications导致的
*
* Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource
*
* */
@Bean
public static ConfigureRedisAction configureRedisAction() {
return ConfigureRedisAction.NO_OP;
}
/**
* 用于spring session,防止每次创建一个线程
* @return
*/
@Bean
public ThreadPoolTaskExecutor springSessionRedisTaskExecutor() {
ThreadPoolTaskExecutor springSessionRedisTaskExecutor = new ThreadPoolTaskExecutor();
springSessionRedisTaskExecutor.setCorePoolSize(8);
springSessionRedisTaskExecutor.setMaxPoolSize(16);
springSessionRedisTaskExecutor.setKeepAliveSeconds(10);
springSessionRedisTaskExecutor.setQueueCapacity(1000);
springSessionRedisTaskExecutor.setThreadNamePrefix("Spring session redis executor thread: ");
return springSessionRedisTaskExecutor;
}
}
遇到了同样的问题,在CSDN看到了,希望阿里云团队能够给出正确、标准的答案~请查看
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。