配置
还没用spring session的时候,一直不明白如何让后端把session主动存到持久层(比如redis)中,这几天看了看spring session的文档和博客,算是明白了,简单来说就是下面一段话:
Spring Session creates a Spring bean with the name of springSessionRepositoryFilter that implements Filter. The filter is in charge of replacing the HttpSession implementation to be backed by Spring Session.
不过spring.io官网的配置tutorial属实不行,配出来根本无法向redis里面插入数据,且给的demo也没法在本机运行。
现在给出我的配置方案
依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency