问题:按照正常的程序将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();
}
}

最新文章

  1. JDK1.3安装出现/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory Done.
  2. gradle项目中资源文件的相对路径打包处理技巧
  3. 梳理源码中 View 的工作原理
  4. [深入浅出Windows 10]布局原理
  5. 自定义StyleCop规则
  6. linux添加时间提示符
  7. Java学习笔记(十八)——Java DTO
  8. tools/build.c
  9. mysql 按年度、季度、月度、周、日SQL统计查询
  10. 如何优化 Android Studio 启动、编译和运行速度?
  11. HDU-4662 MU Puzzle 水题
  12. CANoe 入门 Step by step系列(二)CAPL编程【转】
  13. Android面试,IntentService的原理及使用
  14. FeatureClass Copy
  15. SQL 注入与防御实例
  16. ELK整体方案
  17. 在eclipse总是会运行之前的错误项目
  18. windows下怎么生成github的ssh公钥
  19. 题解 P2920 【[USACO08NOV]时间管理Time Management】
  20. Codeforces 750 F:New Year and Finding Roots

热门文章

  1. Python条件语句和基本数据类型
  2. C/C++中的可变参数
  3. SQL Server创建dblink跨库查询
  4. Docker 安装 PHP+Nginx
  5. Pytorch实战学习(八):基础RNN
  6. springboot外部部署官方文档说明复制版
  7. 【jquery easyUI 拓展
  8. vs code 提交代码弹框提示:请确保已在git中配置您的“user.name”和“user.email” ——解决方法
  9. npm vue-router安装报错
  10. 读后笔记 -- Java核心技术(第11版 卷 II) Chapter2 输入与输出