欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

使用spring session redis实现共享session之后,httpsession监听失效 redisspringhttpsessionsessionSessionDestroyedEvent

程序员文章站 2022-04-24 17:19:02
...
原因是配置了:
<util:constant static-field="org.springframework.session.data.redis.config.ConfigureRedisAction.NO_OP"/>
   这一行。

参考官网文章:
https://docs.spring.io/spring-session/docs/1.1.0.M1/reference/html5/#httpsession-httpsessionlistener

看到这样的一段:
引用
If you are using @EnableRedisHttpSession the SessionMessageListener and enabling the necessary Redis Keyspace events is done automatically. However, in a secured Redis enviornment the config command is disabled. This means that Spring Session cannot configure Redis Keyspace events for you. To disable the automatic configuration add ConfigureRedisAction.NO_OP as a bean.


解决办法:
去掉配置:
<util:constant static-field="org.springframework.session.data.redis.config.ConfigureRedisAction.NO_OP"/>

如果还不行,那就需要开启redis的key失效事件监听。
参考文章:http://blog.csdn.net/aeroleo/article/details/77011839