- 使用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中查看到一条记录。
本文介绍如何使用Spring Boot和Gradle构建项目,并通过配置将Spring Session与Redis集成以实现会话管理。文中详细展示了必要的依赖项、配置步骤及简单的测试方法。
1337

被折叠的 条评论
为什么被折叠?



