springboot中使用redis管理session

编程入门 行业动态 更新时间:2024-10-26 10:31:32

<a href=https://www.elefans.com/category/jswz/34/1769943.html style=springboot中使用redis管理session"/>

springboot中使用redis管理session

前言

使用软件:

redis: 

linux版本下载

windows版本下载

安装redis

下载redis

/

源码安装redis(ubuntu)

#将指定版本的redis上传到服务器#解压
sudo tar -xzvf redis-6.2.4.tar.gzcd redis-6.2.4#编译
sudo make#执行完 make 命令后,redis-6.2.4 的 src 目录下会出现编译后的 redis 服务程序 redis-server,还有用于测试的客户端程序 redis-cli#下面启动 redis 服务:cd srcsudo ./redis-server#客户端
cd src
sudo ./redis-cli

springboot中配置redis

添加pom依赖

<!--Redis依赖-->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-redis</artifactId><version>1.4.7.RELEASE</version>
</dependency>
<dependency><groupId>org.springframework.session</groupId><artifactId>spring-session-data-redis</artifactId>
</dependency>

Redis数据库的配置(application.yml)

spring:  redis:host: 127.0.0.1port: 6379password:database: 0lettuce:pool:max-active: 32  #最大连接max-wait: 300ms  #最小空闲连接max-idle: 16  #最大空闲连接min-idle: 8  #最小空闲连接

使用方法

和原始使用session一样不变,springboot自动使用redis管理session。

windows中的效果显示

更多推荐

springboot中使用redis管理session

本文发布于:2023-11-16 22:59:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636003.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:springboot   redis   session

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!