使用Spring Session和Redis管理session
2017-06-21 17:47
1071 查看
使用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配置:
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
加入spring session 配置:
1
最后进行测试
2
3
4
5
6
7
1
2
3
4
5
6
7
还是原来使用session的方式,可以在redis中查看到一条记录。
加入依赖
compile ‘org.springframework.session:spring-session:1.2.0.RELEASE’
compile ‘org.springframework.boot:spring-boot-starter-data-redis’
使用注解 @EnableRedisHttpSession
application.properties配置
加入redis配置:
spring.redis.database=0 spring.redis.host=localhost spring.redis.password= spring.redis.pool.max-active=8 spring.redis.pool.max-idle=8 spring.redis.pool.max-wait=-1 spring.redis.pool.min-idle=0 spring.redis.port=63791
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
加入spring session 配置:
spring.session.store-type=redis1
1
最后进行测试
@RequestMapping("/") @ResponseBody String home(HttpSession session) { session.setAttribute("test", new Date()); return "Hello World!"; }1
2
3
4
5
6
7
1
2
3
4
5
6
7
还是原来使用session的方式,可以在redis中查看到一条记录。
相关文章推荐
- 使用Spring Session和Redis管理session
- tomcat 使用redis 管理session
- Spring boot入门系列(三):使用Redis进行Session的管理
- 【Redis】Redis学习笔记02_使用Redis来管理Tomcat集群的Session
- 详解nodejs express下使用redis管理session
- tomcat-redis-session管理 使用说明
- laravel5.3使用redis管理session解决session共享问题
- 使用shiro和redis结合,管理SessionDAO的对Session的CRUD,并源码分析
- Spring MVC 使用 Spring Session 实现 Session 共享-Redis
- 使用过滤器来处理Session超时和权限管理
- 牛腩 45 整合类别管理(1) session未将对象引用设置到对象的实例,repeater控件的使用,linkbutton的删除
- Tomcat集群session管理解决方案(关于sticky session、session replication与使用memcached缓存session)
- ASP.NET下跨应用共享Session和使用Redis进行Session托管
- 使用git管理nodejs+socket.io+redis+juicer+waterfall+ubuntu+aws ec2开发网站
- windows redis (php-redis插件,redis-admin管理工具)使用
- ,使用session_set_save_handler,接管所有的session管理工作流程
- Session的使用与管理
- s2sh整合使用spring管理session连接没有关闭
- Hi!欢迎使用一个Dynamo风格的分布式Redis集群分发管理系统WheatRedis - V2EX
- Redis实践:使用Pub/Sub实现对服务器群的管理监控