这篇文章给大家聊聊关于后端处理session超时,以及后端处理session超时对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。
Spring Session
简化集群中的?户会话管理?需绑定容器特定解决?案
?持的存储
RedisMongoDBJDBCHazelcast实现原理定制 HttpSession
通过定制的 HttpServletRequest 返回定制的 HttpSession
SessionRepositoryRequestWrapperSessionRepositoryFilterDelegatingFilterProxy基于 Redis 的 HttpSession引?依赖spring-session-data-redis基本配置@EnableRedisHttpSession提供 RedisConnectionFactory实现 AbstractHttpSessionApplicationInitializer配置 DelegatingFilterProxy
Spring Boot 对 Spring Session 的?持
application.properties
spring.session.store-type=redisspring.session.timeout=server.servlet.session.timeout=spring.session.redis.flush-mode=on-savespring.session.redis.namespace=spring:sessionSpringSession
Spring Boot为广泛的数据存储提供Spring Session自动配置。在构建servlet web应用程序时,可以自动配置以下存储:
JDBCRedisHazelcastMongoDB
此外,Spring Boot for Apache Geode提供了 auto-configuration for using Apache Geode as a session store。
servlet自动配置取代了使用@Enable*HttpSession的需要。
在构建响应式web应用程序时,可以自动配置以下存储:
RedisMongoDB
响应式自动配置取代了使用@Enable*WebSession的需要。
如果类路径上存在一个Spring Session模块,Spring Boot会自动使用该存储实现。如果有多个实现,则必须选择希望用于存储会话的StoreType。例如,要使用JDBC作为后端存储,您可以如下配置您的应用程序:
spring.session.store-type=jdbc
你可以通过设置store类型为none来禁用Spring Session。
每个存储都有特定的附加设置。例如,可以为JDBC存储自定义表的名称,如下面的示例所示:

spring.session.jdbc.table-name=SESSIONS
要设置会话的超时时间,你可以使用spring.session.timeout属性。如果没有使用servlet web应用程序设置该属性,自动配置将退回到server.servlet.session.timeout的值。
您可以使用@Enable*HttpSession (servlet)或@Enable*WebSession(响应式)来控制Spring Session的配置。这将导致自动配置退出。然后可以使用注解的属性而不是前面描述的配置属性来配置Spring Session。
OK,本文到此结束,希望对大家有所帮助。