<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns='http://www.springframework.org/schema/beans'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:util='http://www.springframework.org/schema/util'
xsi:schemaLocation='
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
'>
<!--class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"-->
<bean name="redisHttpSessionConfiguration"
class="com.liubin.study.session.redis.MyRedisHttpSessionConfiguration">
<!--session存在的时间-->
<property name="maxInactiveIntervalInSeconds" value="180"/>
<!--关闭redis的发布和订阅-->
<property name="configureRedisAction">
<util:constant static-field="org.springframework.session.data.redis.config.ConfigureRedisAction.NO_OP"/>
</property>
<!--添加监听器-->
<property name="httpSessionListeners">
<ref bean="httpSessionListeners"/>
</property>
</bean>
<!--对于redis中的数据的序列化和反序列化-->
<bean name="springSessionDefaultRedisSerializer"
class="com.liubin.study.session.redis.Fastjson2JsonRedisSerializer"/>
<!--
对于sessionId存储的处理
(默认为Cookie存储)
-->
<!--使用cookie存储
<bean name="cookieHttpSessionStrategy" class="org.springframework.session.web.http.CookieHttpSessionStrategy"/>
-->
<!--使用http首部来存储
<bean name="headerHttpSessionStrategy" class="org.springframework.session.web.http.HeaderHttpSessionStrategy"/>
-->
<!--对于存储在redis中的session信息的监听-->
<util:list id="httpSessionListeners">
<bean class="com.liubin.study.session.redis.listeners.BasicHttpSessionListener"/>
</util:list>
</beans>
spring-session 使用redis来存储session配置文件
最新推荐文章于 2023-10-25 17:10:22 发布