阿里与Redis 利用redis实现session共享

报错如下:
[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;
    }

}

报连接redis服务器错误,看看host的ip、端口是否是redis服务器的ip和端口,以及用户名密码是否正确

看你这台服务器与阿里云redis之间的网络通不通。阿里云redis的话应该是给你提供了一个供访问用的域名吧,排查下看看ping和telnet这个域名通不通,然后看看redis控制台上有没有防火墙、安全组之类的设置。