一、創建項目並導入依賴
<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運行第二個項目
效果圖