Spring Redis Session

First Post:

Last Update:

Word Count:
123

Read Time:
1 min

通过Spring Session实现Session的共享

  1. 通过maven导入相关的依赖。

  2. 在web.xml中添加如下Filter.

    1
    2
    3
    4
    5
    6
    7
    8
    <filter>
    <filter-name>springSessionRepositoryFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>springSessionRepositoryFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
  3. 在spring 配置文件中导入如下bean

    1
    <bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"/>
  4. 完成后多个application就可以访问共用session.

打赏
支付宝 | Alipay
微信 | WeChat