SpringBoot Session共享实现图解

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

SpringBoot Session共享实现图解

  2021-04-02 我要评论

这篇文章主要介绍了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层

三、打包测试

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

在cmd中运行第一个项目

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

控制台复制

再在cmd运行第二个项目

效果图

您可能感兴趣的文章:

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们