我的应用程序目前使用Spring Session和Redis作为后端。
我搜索了official documentation for Spring Session,但在使用该模块时找不到默认的会话超时。
此外,如果需要,我也不确定如何更改默认超时。
有人能给点建议吗?
发布于 2015-09-12 06:44:25
在使用redis存储库时,配置会话超时的最简单方法是
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 60)或@EnableRedissonHttpSession(maxInactiveIntervalInSeconds = 1200)。
当存储库中不再提供该会话时,该会话将过期。可以在RedisOperationsSessionRepository和MapSessionRepository上使用setDefaultMaxInactiveInterval(int)配置超时。默认值为30 minutes。
如果您使用的是spring boot,那么从1.3版开始,它将自动将该值与应用程序配置中的server.session.timeout属性同步。
请注意,使用spring session时的一个缺点是没有调用javax.servlet.http.HttpSessionListener。
如果需要对会话过期事件做出反应,可以订阅spring应用程序的SessionDestroyedEvent应用程序事件。
发布于 2019-05-24 18:17:19
在Spring Boot2.0中,server.session.timeout已被弃用,并被替换为server.servlet.session.timeout。
https://stackoverflow.com/questions/32501541
复制相似问题