问题:按照正常的程序将session 共享引入工程,但是一直取不到

原因:springboot 的版本不同导致,存session的springboot 用的是springboot1.5.6,而取session的springboot版本是2.1.5。

解决方式1:统一springboot的版本(特别推荐)

解决方式2:改变部分jar的版本(权宜之计-兼容)

compile('org.springframework.session:spring-session-data-redis')
compile('org.springframework.security.oauth:spring-security-oauth2:2.0.14.RELEASE')
{
exclude module: 'org.slf4j:slf4j-api' exclude module: 'org.springframework.security:spring-security-core'
exclude module: 'org.springframework.security:spring-security-config'
exclude module: 'org.springframework.security:spring-security-crypto'
exclude module: 'org.springframework.security:spring-security-web'
}
compile('org.springframework.security:spring-security-core:4.2.19.RELEASE')
compile('org.springframework.security:spring-security-config:4.2.19.RELEASE')
compile('org.springframework.security:spring-security-crypto:4.2.19.RELEASE')
compile('org.springframework.security:spring-security-web:4.2.19.RELEASE')

 共享session的配置类 

@Configuration
@EnableRedisHttpSession
public class HttpSessionConfig { @Bean
public DefaultCookieSerializer defaultCookieSerializer(){
DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
cookieSerializer.setUseBase64Encoding(false);
return cookieSerializer;
} }

 请求

head:

Cookie:SESSION=145485qwedwa778djwahijheqw

spring.session.store-type = redis
security.headers.cache = false
security.sessions = NEVER
security.user.name =
security.user.password =
package com.XXXXXXX.marketcontrol.manager.config;

import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @Configuration
@Order(SecurityProperties.BASIC_AUTH_ORDER)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.httpBasic()
.and()
.authorizeRequests()
.antMatchers("/", "/app/**", "/pub/**", "/api/**","/opera/**").permitAll()
.antMatchers("/**").permitAll()
.anyRequest().authenticated()
.and()
.csrf().disable()
.headers().defaultsDisabled().cacheControl();
}
}

session共享问题、springboot 版本不统一问题的更多相关文章

  1. 【快学springboot】11.整合redis实现session共享

    前言 这里都是基于前面的项目基础上的.springboot整合redis非常的方便,这也是springboot的宗旨,简化配置.这篇文章就教大家如何使用springboot整合redis来实现sess ...

  2. springboot+redis实现session共享

    1.场景描述 因项目访问压力有点大,需要做负载均衡,但是登录使用的是公司统一提供的单点登录系统,需要做session共享,否则假如在A机器登录成功,在B机器上操作就会存在用户未登录情况. 2. 解决方 ...

  3. 从.Net到Java学习第八篇——SpringBoot实现session共享和国际化

    从.Net到Java学习系列目录 SpringBoot Session共享 修改pom.xml添加依赖 <!--spring session--> <dependency> & ...

  4. 二十三、springboot之session共享

    通过redis实现session共享 SpringBoot集成springsession 1.引入依赖(gradle方式) dependencies { compile('org.springfram ...

  5. springboot+spring session+redis+nginx实现session共享和负载均衡

    环境 centos7. jdk1.8.nginx.redis.springboot 1.5.8.RELEASE session共享 添加spring session和redis依赖 <depen ...

  6. 基于SpringBoot+Redis的Session共享与单点登录

    title: 基于SpringBoot+Redis的Session共享与单点登录 date: 2019-07-23 02:55:52 categories: 架构 author: mrzhou tag ...

  7. SpringBoot 整合Shiro实现动态权限加载更新+Session共享+单点登录

    作者:Sans_ juejin.im/post/5d087d605188256de9779e64 一.说明 Shiro是一个安全框架,项目中主要用它做认证,授权,加密,以及用户的会话管理,虽然Shir ...

  8. springboot(十八)-session共享

    前言 在传统的单服务架构中,一般来说,只有一个服务器,那么不存在 Session 共享问题,但是在分布式/集群项目中,Session 共享则是一个必须面对的问题,先看一个简单的架构图: 在这样的架构中 ...

  9. SpringBoot一个依赖搞定session共享

    原文:微信公众号:Java开发宝典  https://mp.weixin.qq.com/s/_VFY9lXqNhH8Nh4HC9tuMg 1. 前言 在传统的单服务架构中,一般来说,只有一个服务器,那 ...

  10. springboot集成springsession利用redis来实现session共享

    转:https://www.cnblogs.com/mengmeng89012/p/5519698.html 这次带来的是spring boot + redis 实现session共享的教程. 在sp ...

随机推荐

  1. SSL certificate problem: unable to get local issuer certificate 错误解决

    终端报了如下错误git SSL certificate problem: unable to get local issuer certificate 这个问题是由于没有配置信任的服务器HTTPS验证 ...

  2. 【QT+MSVC2015】不安装VS2015,QT配置MSVC2015编译环境

    本文介绍不安装VS2015的情况下在QT5.10中配置MSVC2015编译器. 系统:windows系统 QT版本:5.10.1 所需文件: QT安装程序--qt-opensource-windows ...

  3. 思科数据中心CCIE稳定PASS

    乾颐堂DC数据中心CCIE,在增加新题的情况下一次PASS! 目前笔试.lab都在过人,需要备考的同学联系乾颐堂,机时充足!

  4. CentOS7桥接网络设置(小白向)

    配置过程 查看网卡设备名:输入ifconfig 可以看到网卡设备名是ens32 注:不同版本网卡设备名是不一样的 进入到默认文件路径,输入:cd /etc/sysconfig/network-scri ...

  5. Quartz.Net的简单使用

    1.安装Quartz.Net Install-Package Quartz -Version 2.5.0 2.需要执行定时任务的代码,新建一个类,继承IJob接口,并实现该接口 public clas ...

  6. es实现规格动态域生成

    1.就是把sepc的可以提取出来作为一个域(sepc是一个规格参数) 封装搜索条件(跟jdbc流程一样) @requestparam( required = false) 的作用?   不传值后台也不 ...

  7. 哲讯科技SAP医疗器械行业ERP解决方案

    哲讯科技SAP医疗器械行业ERP解决方案主要体现在以预测为指导,计划为执行的管理理念,完全做到实时的全过程的质量管理和质量跟踪.并且通过灵活的质量管理模块大大降低因实施GMP管理给企业带来的成本压力. ...

  8. Docker CLI docker build 常用命令

    Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux或Windows操作系统的机器上,也可以实现虚拟化.Docker是内核 ...

  9. params的使用

    今天在写vue的JavaScript的时候有个地方需要传很多参数,自己写不出来,求助 我的博博 后拿到神奇代码: 神奇代码中有params,俺自作聪明,以为他是一个json的数据,所以自己改了个名字 ...

  10. 【服务器数据恢复】热备盘同步失败导致数据丢失的raid5数据恢复案例

    服务器数据恢复环境:华为s系列服务器:24块硬盘组成一组raid5磁盘阵列,其中包含1块热备盘. 服务器故障&检测:服务器工作状态下raid5中有一块硬盘离线,热备盘激活替换离线硬盘并开始进行 ...