项目框架是使用 springboot 框架
宗旨:session 序列化到到 redis 里面,各个微服务 session 取值,都从redis 中获取
maven pom.xml 文件中 引入 redis jar 包,举例
user 用户中心 微服务中pom.xml 文件添加 redis 依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
UserApplication 中加入
@EnableRedisHttpSession
然后 正常的 session 存储 获取值 即可使用了