一、在 pom.xml 添加 Springsession
<!-Springsession-> <Depopentcy> <gruppe> org.springframework.Session </Groupid> <artifactid> Spring-Session-Data-Redis </artifactid> <version> 1.2.0.Release </Version> </abhängig>
二、确保 Feder 是 4.3.10.Release 版本以上
<Depopenty> <gruppe> org.springFramework </Groupid> <artifactid> Spring-Context </artifactId> <version> 4.3.10.Release </Version> </abhängig>
三、 applicationContext.xml 文件中添加四个 Bean 类
<bean id = "redishttpSessionConfiguration"> <Eigenschaft name = "MaxinactiveIntervalinseconds" value = "180"> </property> </bean> <bean id = "jedispoolconfig"> </bean> <bean id = "jedisconnectionFactory"> <Property ". name = "port" value = "6379"> </property> <Eigenschaft name = "poolconfig" ref = "jedispoolconfig"> </property> </bean> <bean id = "defaultCookieSerializer"> <Eigenschaft name = "Cookiene" Value = "SpringSession"> </Property> </Property ". value = "3600"/> <Eigenschaft name = "usehtttponlycookie" value = "true"/> <Eigenschaft name = "DomainName" value = ". qs.com"/> </bean>
这样就可以实现 Sitzung 享 , , nginx 下的 tomcat 集群也是这样的
原理就是 : 通过 Springsession 对 Servlet 带的 Sitzung 进行封装 , 接管 Sitzung