前言:
session共享策略有很多,我这里说的SpringSession无缝整合redis。
第一步:引入依赖:SpringSession和redis的依赖(版本号自己选择)
<!-- 使用Spring Session来解决Session共享问题 -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
第二步:配置properties文件
spring.redis.host=localhost
spring.redis.port=6379