Advertisement

微服务非登录功能基于Spring Session和Spring Security的实践

阅读量:

配置

当还没有采用Spring Session时,我总是不清楚如何使后端将Session数据主动持久化到存储层(如Redis数据库)中。近来仔细阅读了Spring Session的相关文档以及相关的博客文章后终于搞懂了。具体来说,请参考以下内容。

Spring Session通过名称springSessionRepositoryFilter生成一个SpringBean,并且该Bean实现了Filter接口。过滤器负责将HttpSession替换成由SpringSession支持的实现。

但是spring.io官网上的配置教程确实不可行。它导致的数据无法被插入到Redis中,并且提供的演示文件也无法在我的本地环境中运行。现在我将提供我的配置方案。

依赖

复制代码
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
    <dependency>

全部评论 (0)

还没有任何评论哟~