session共享问题、springboot 版本不统一问题
2024-09-08 17:54:25
问题:按照正常的程序将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();
}
}
最新文章
- JDK1.3安装出现/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory Done.
- gradle项目中资源文件的相对路径打包处理技巧
- 梳理源码中 View 的工作原理
- [深入浅出Windows 10]布局原理
- 自定义StyleCop规则
- linux添加时间提示符
- Java学习笔记(十八)——Java DTO
- tools/build.c
- mysql 按年度、季度、月度、周、日SQL统计查询
- 如何优化 Android Studio 启动、编译和运行速度?
- HDU-4662 MU Puzzle 水题
- CANoe 入门 Step by step系列(二)CAPL编程【转】
- Android面试,IntentService的原理及使用
- FeatureClass Copy
- SQL 注入与防御实例
- ELK整体方案
- 在eclipse总是会运行之前的错误项目
- windows下怎么生成github的ssh公钥
- 题解 P2920 【[USACO08NOV]时间管理Time Management】
- Codeforces 750 F:New Year and Finding Roots
热门文章
- Python条件语句和基本数据类型
- C/C++中的可变参数
- SQL Server创建dblink跨库查询
- Docker 安装 PHP+Nginx
- Pytorch实战学习(八):基础RNN
- springboot外部部署官方文档说明复制版
- 【jquery easyUI 拓展
- vs code 提交代码弹框提示:请确保已在git中配置您的“user.name”和“user.email” ——解决方法
- npm vue-router安装报错
- 读后笔记 -- Java核心技术(第11版 卷 II) Chapter2 输入与输出