spring-session 使用redis来存储session配置文件

<?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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值