Spring-session Redis Cluster Configuration steps Summary

Source: Internet
Author: User
Tags redis cluster

    1. Summarize configuration steps

Four simple steps to start spring-session Redis configuration Life

1. Pom.xml Add jar Dependency
<project xmlns= "http://maven.apache.org/POM/4.0.0"  xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance " xsi:schemalocation=" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ Xsd/maven-4.0.0.xsd ">    <modelVersion>4.0.0</modelVersion>     ....    <properties>        < version.spring-session>1.2.2.release</version.spring-session>         <!--not compatible  1.7.4.RELEASE -->        < version.spring-data-redis>1.7.1.release</version.spring-data-redis>    </ properties>    <dependencies>                 <dependency>             <groupid>org.springframework.session</groupid>             <artifactId>spring-session</artifactId>             <version>${version.spring-session}</version>         </dependency>        <dependency>             <groupid>org.springframework.session </groupId>            <artifactId> spring-session-data-redis</artifactid>             <version>${version.spring-session}</version>         </dependency>        <dependency>             <groupid>org.springframework.data</groupid>             <artifactId>spring-data-redis</artifactId>             <version>${version.spring-data-redis}</ version>        </dependency>          ....    </dependencies></project>
2. Web. XML add springsessionrepositoryfilter Configuration download
    <?xml version= "1.0"  encoding= "UTF-8"?>    < web-app version= "3.0"  xmlns= "Http://java.sun.com/xml/ns/javaee"  xmlns:xsi= "http://www.w3.org/ 2001/xmlschema-instance "        xsi:schemalocation=" http// Java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd ">         ...        <!-- spring-session  config -->        <context-param>             <param-name>contextconfiglocation</param-name >            <param-value>                 classpath*: Spring-session-cluster.xml            </param-value>         </context-param>        <!--  This filter  to be put on the first  -->        <filter>             <filter-name>springSessionRepositoryFilter</filter-name>             <filter-class> org.springframework.web.filter.delegatingfilterproxy</filter-class>         </filter>        <filter-mapping>             <filter-name>springsessionrepositoryfilter </filter-name>            <url-pattern >/*</url-pattern>            <dispatcher>request</dispatcher>             <dispatcher>ERROR</dispatcher>         </filter-mapping>         ...    </web-app>
3. Spring-session-cluster.xml Download
    <?xml version= "1.0"  encoding= "UTF-8"?>    < beans xmlns= "Http://www.springframework.org/schema/beans"  xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance " xmlns:context=" Http://www.springframework.org/schema/context "         xmlns:p= "http://www.springframework.org/schema/p"  xmlns:util= "http// Www.springframework.org/schema/util "        xsi:schemalocation=" http:/ /www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd             http://www.springframework.org/schema/ context http://www.springframework.org/schema/context/spring-context.xsd             http://www.springframework.org/schema/util http:// www.springframework.org/schema/util/spring-util.xsd                ">         <context:annotation-config />         <util:properties id= "Redis"  location= "Classpath:redis-cluster.properties" ></ util:properties>        <!-- redishttpsessionconfiguration  -->        <bean class= " Org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration " />         <!--jedisconnectionfactory -->         <bean class= " Org.springframework.data.redis.connection.jedis.JedisConnectionFactory ">             <constructor-arg index= "0" >                 <!-- since spring-data-redis 1.7  -->                 <bean class= "Org.springframework.data.redis.connection.RedisClusterConfiguration" >                      <constructor-arg index= "0" >                         <set>                              <value>#{redis[' Redis.redisClusterConfiguration.clusters ']}</ value>                         </set>                     </constructor-arg>                     <!--                           for  redis.clients.jedis.jediscluster.jediscluster (set4. Redis-cluster.properties download 
    ############ #for   org.springframework.data.redis.connection.redisclusterconfiguration###################     #只需要配置  master     #理论上只需要配置一个节点即可, multiple configurations are designed to prevent a single node from hanging off,     redis.redisclusterconfiguration.clusters=10.88.21.31:10000,10.88.22.25:10000,10.88.21.31:10001      #用于  redis.clients.jedis.jediscluster.jediscluster (Set


Spring-session Redis Cluster Configuration steps Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.