问题:按照正常的程序将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. 【Linux】ArchLinux 使用之旅

    主要参考以下两个链接进行,安装系统和安装桌面环境. 以官方Wiki的方式安装ArchLinux | viseator's blog ArchLinux安装后的必须配置与图形界面安装教程 | visea ...

  2. web基础(6): CSS综合实例-咖啡网页设计

    咖啡店案例效果图 (一)页面的布局 1. 最上方的header:右下角是四个小图标,像图层一样附加在当前的header部分上. 2. 超链接构成的导航栏,鼠标悬浮的时候字体颜色发生变化. 3. 主体分 ...

  3. nginx热更新流程记录

    已经做过不止一次的nginx热更新了,之前都是按照别人的路子照葫芦画瓢,现在根据我在的项目单独写一个nginx热更新流程备份自用. nginx热升级流程上传新tar到/home/cp命令复制到/usr ...

  4. CRON表达式转换成中文

    目录 1,cron表达式生成器 2,cron表达式 一,结构 二.各字段的含义 三.常用表达式例子 3,转换成中文: 1,CronExpParserUtil 2,WeekEnum 3,测试: 4,测试 ...

  5. tensorrt cuda cudnn 各版本的匹配要求

    https://docs.nvidia.com/deeplearning/tensorrt/release-notes/tensorrt-8.html#rel_8-0-3

  6. CentOS系统上离线部署MySQL

    卸载自带Mariadb 1.[卸载前确认系统是首次安装使用,以防止误删用户数据],初次安装默认系统会自带Mariadb,卸载moriadb. 操作方式: 查找:# rpm -qa|grep maria ...

  7. REPLACE,TRANSLATE

    REPLACE 1.语法 replace(string,from_str,to_str) 2.说明: 针对string,将from_str中的字符替换为to_str中字符. 3.示例: /**说明:( ...

  8. vue3介绍-vue3创建项目-setup函数-ref和reactive-计算属性和监听-生命周期-toRefs-script setup的作用和lang=ts-vue后台管理模板

    目录 vue3介绍-vue3创建项目-setup函数-ref和reactive-计算属性和监听-生命周期-toRefs-script setup的作用和lang=ts-vue后台管理模板 昨日内容回顾 ...

  9. Android版本历史

    版本 Code Name 代号 API 日期 NDK 1.0 Astro 铁臂阿童木  1     1.1 Bender, Petit Four 发条机器人 2     1.5 Cupcake  纸杯 ...

  10. WIN10操作系统如何利用无线网卡连接wifi再通过有线网卡共享网络给路由(双网卡)

    首先有一台笔记本电脑,或者双网卡的电脑(wifi网卡 和 有线网卡) 找到两个个网卡,并重置他们的设置 然后同时选中,右单击选择桥接 桥接成功以后就可以用无线网卡连接wifi,然后把有线网口插上网线直 ...