pom.xml 添加 Springsession
<!-Springsession-> <pectionency> <groupId> org.springframework.session </groupId> <artifactid> Spring-Session-Data-Redis </artifactid> <bersion> 1.2.0. Release </version> </dependency>
Spring 3. 4.3.10. release 版本以上
<pectionency> <groupid> org.springframework </groupid> <artifactid> spring-context </artifactid> <버전> 4.3.10. release </version> </fectionency>
三、 applicationcontext.xml 文件中添加四个 bean 类
<bean id = "redishttpsessionconfiguration"> <property name = "maxInactiveIntervalinseconds"value = "180"> </property> </bean> <bean> <bean id = "jedispoolconfig"> </bean> <bean id = "jediscontectory"> <property name = "hostname" "127.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1. value = "6379"> </property> <property name = "poolconfig"ref = "jedispoolconfig"> </property> </bean> <bean id = "defaultCookieserializer"> <property name = "chookiename"value = "springsession"> </property> <property name = "cookiepath"/"> <Property Name ="CoopiEmaxage " 값 = "3600"/> <속성 이름 = "usehttponlyCookie"value = "true"/> <속성 이름 = "domainName"value = ". qs.com"/> </bean>
SESSION 세션 ff, nginx 下的 Tomcat 集群也是这样的
原理就是 : 通过 Springsession 对 Servlet SESSION CASSION, 接管 세션