欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  类库下载

spring-session redis集群配置步骤总结

程序员文章站 2022-03-20 18:37:46
...
总结配置步骤

简单四步,开始 spring-session redis 配置人生

1. pom.xml 添加 jar依赖

4.0.0

    ....

    1.2.2.RELEASE1.7.1.RELEASE

        ....

        org.springframework.sessionspring-session${version.spring-session}org.springframework.sessionspring-session-data-redis${version.spring-session}org.springframework.dataspring-data-redis${version.spring-data-redis} 

        ....

    

2. web.xml 添加 springSessionRepositoryFilter 配置下载

 

        ...        
        contextConfigLocation
                classpath*:spring-session-cluster.xml
            springSessionRepositoryFilterorg.springframework.web.filter.DelegatingFilterProxyspringSessionRepositoryFilter/*REQUESTERROR
        ...
    

3. spring-session-cluster.xml下载

    #{redis['redis.redisClusterConfiguration.clusters']}

4. redis-cluster.properties下载

    #############for org.springframework.data.redis.connection.RedisClusterConfiguration###################
    #只需要配置 master
    #理论上只需要配置一个节点即可,配置多个是为了防止单个节点挂掉,
    redis.redisClusterConfiguration.clusters=10.88.21.31:10000,10.88.22.25:10000,10.88.21.31:10001    #用于 redis.clients.jedis.JedisCluster.JedisCluster(Set, int, int, GenericObjectPoolConfig) 第三个参数 maxRedirections
    #默认值是5
    #一般当此值设置过大时,容易报:Too many Cluster redirections
    redis.redisClusterConfiguration.maxRedirects=3    ###########for redis.clients.jedis.JedisPoolConfig##############################

    redis.jedisPoolConfig.MaxIdle=60000    redis.jedisPoolConfig.testOnBorrow=true    redis.jedisPoolConfig.testOnReturn=true    #新版jedis 不支持这个参数了
    #redis.jedisPoolConfig.MaxActive=50
    #redis.jedisPoolConfig.MaxWait=5000