- 使用Spring Boot以及Gradle构建项目
- 加入依赖
compile ‘org.springframework.session:spring-session:1.2.0.RELEASE’
compile ‘org.springframework.boot:spring-boot-starter-data-redis’ - 使用注解 @EnableRedisHttpSession
- application.properties配置
加入redis配置:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
加入spring session 配置:
- 1
- 1
最后进行测试
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
还是原来使用session的方式,可以在redis中查看到一条记录。