- 使用Tomcat+Redis
我们可以在Tomcat的配置文件中进行设置,设置成功之后,Tomcat会将Session存储到Redis中,这样我们访问不通的Tomcat时,可以保证session是共享的。 context.xml文件
- 使用Spring Session+Redis
我们可以使用Spring Session和Redis实现共享存储Session,这样就不依赖部署的Web容器。下面我们简单讲解一些配置和使用,感兴趣的小伙伴可以动手试试。 依赖:pom.xml
org.springframework.session
spring-session-data-redis
1.2.1.RELEASE
redis.clients
jedis
2.8.1
配置文件:
web.xml
springSessionRepositoryFilter
org.springframework.web.filter.DelegatingFilterProxy
springSessionRepositoryFilter
/*
Original: https://www.cnblogs.com/aibianchengya/p/16804714.html
Author: 程序猿的代码
Title: 分布式Session如何存储
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/644075/
转载文章受原作者版权保护。转载请注明原作者出处!