SpringBoot Session共享图解

小编给大家分享一下SpringBoot Session共享图解,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

一、创建项目并导入依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>

二、相关配置和代码

Application.properies

spring.redis.database=0
spring.redis.password=fernfei
spring.redis.host=192.168.21.130
spring.redis.port=6379
server.port=8080

Controller层

SpringBoot Session共享图解

三、打包测试

SpringBoot Session共享图解

双击打包,注意打包时把test跳过,点那个闪电就可以跳过测试

在cmd中运行第一个项目

SpringBoot Session共享图解

使用新版redis必须导入security,security访问项目时需要登陆,用户名user密码

控制台复制

SpringBoot Session共享图解

再在cmd运行第二个项目

SpringBoot Session共享图解

效果图

SpringBoot Session共享图解

SpringBoot Session共享图解

以上是“SpringBoot Session共享图解”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注恰卡编程网行业资讯频道!

发布于 2021-05-30 14:06:26
收藏
分享
海报
0 条评论
178
上一篇:从EFCore上下文的使用到深入剖析DI的生命周期最后实现自动属性注入的示 下一篇:HTML5如何去掉输入框type为number时的上下箭头
目录

    0 条评论

    本站已关闭游客评论,请登录或者注册后再评论吧~

    忘记密码?

    图形验证码