传统捞项目基于servlet容器 cookie单体会话改造分布式会话方案
##引入redis,spring-session依赖
<!--redis依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><dependency><groupId>org.springframework.session</groupId><artifactId>spring-session-data-redis</artifactId></dependency>
##修改配置文件
spring:application:name: hnmop-consumersession:timeout: 3600store-type: redisredis:namespace: yym:sessionredis:lettuce:pool:max-idle: 50min-idle: 10max-wait: 300max-active: 25timeout: 30000cluster:nodes:- 192.168.3.156:6379- 192.168.3.156:6380- 192.168.3.156:6381- 192.168.3.156:6382- 192.168.3.156:6383- 192.168.3.156:6384
# - redis-service.hdsst-ns.svc.cluster.local:6379
# - redis-service.hdsst-ns.svc.cluster.local:6379
# - redis-service.hdsst-ns.svc.cluster.local:6379
# - redis-service.hdsst-ns.svc.cluster.local:6379
# - redis-service.hdsst-ns.svc.cluster.local:6379
# - redis-service.hdsst-ns.svc.cluster.local:6379password: 123456database: 0
##启动类加入EnableRedisHttpSession注解
@EnableRedisHttpSession(redisNamespace = "yym:session", maxInactiveIntervalInSeconds = 3600)
##原理
##spring自动配置spring.factories
##生成SessionRepositoryFilter过滤器对象
##使用包装的SessionRepositoryRequestWrapper的request SessionRepositoryResponseWrapper的response