Spring boot 整合 shiro 出现 org.apache.shiro.UnavailableSecurityManagerException: 错误
最开始参考的是这个 文档 但是并没有解决我的问题,因为他的配置和我的是一样(差不多)的
https://www.cnblogs.com/ginponson/p/6217057.html
然后看到此篇博客
https://bbs.csdn.net/topics/391924615
<!-- 相当于调用SecurityUtils.setSecurityManager(securityManager) -->
<bean
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod"
value="org.apache.shiro.SecurityUtils.setSecurityManager" />
<property name="arguments" ref="securityManager" />
</bean>
https://www.cnblogs.com/kibana/p/8953566.html 这篇讲述了 如何配置 MethodInvokingFactoryBean
以下是我的配置
//主要是这个,但是需要用到 getSecurityManager 所有就贴出来
@Bean
public MethodInvokingFactoryBean getMethodInvokingFactoryBean() {
MethodInvokingFactoryBean methodInvokingFactoryBean=new MethodInvokingFactoryBean();
methodInvokingFactoryBean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
methodInvokingFactoryBean.setArguments(getSecurityManager());
return methodInvokingFactoryBean;
} /**
* 创建 DefaultWebSecurityManager
* 需要关联一个Realm
* @Qualifier 获取指定的Bean
* @return
*/
@Bean(name = "webSecurityManager")
public SecurityManager getSecurityManager(){
DefaultWebSecurityManager webSecurityManager=new DefaultWebSecurityManager();
/**
* 配置缓存测量
*/
//配置redis缓存策略
RedisCacheManager redisCacheManager = shiroRedisCache().getCacheManager();
webSecurityManager.setCacheManager(redisCacheManager); //配置 session 管理
SessionManager sessionManager =shiroSessionCache(redisCacheManager).sessionManager();
webSecurityManager.setSessionManager(sessionManager); /**
* 关联多个Realm
*/
Collection<Realm> realms =new ArrayList<>();
// realms.add(realmExtension().getJwtRealm());
realms.add(realmExtension().getUserRealm(doorwayService));
webSecurityManager.setRealms(realms);
Collection<SessionListener> listeners = new ArrayList<>();
return webSecurityManager;
}
Spring boot 整合 shiro 出现 org.apache.shiro.UnavailableSecurityManagerException: 错误的更多相关文章
- spring boot 整合 shiro
shrio官网:https://shiro.apache.org/ Apache Shiro是一个功能强大且易于使用的Java安全框架,可执行身份验证,授权,加密和会话管理.借助Shiro易于理解的A ...
- Spring Boot 整合 Shiro ,两种方式全总结!
在 Spring Boot 中做权限管理,一般来说,主流的方案是 Spring Security ,但是,仅仅从技术角度来说,也可以使用 Shiro. 今天松哥就来和大家聊聊 Spring Boot ...
- Spring Boot2 系列教程(三十二)Spring Boot 整合 Shiro
在 Spring Boot 中做权限管理,一般来说,主流的方案是 Spring Security ,但是,仅仅从技术角度来说,也可以使用 Shiro. 今天松哥就来和大家聊聊 Spring Boot ...
- Spring boot整合shiro框架
ShiroConfiguration package com.energy.common.config; import java.util.LinkedHashMap; import java.uti ...
- 上手spring boot项目(二)之spring boot整合shiro安全框架
题记:在学习了springboot和thymeleaf之后,想完成一个项目练练手,于是使用springboot+mybatis和thymeleaf完成一个博客系统,在完成的过程中出现的一些问题,将这些 ...
- spring boot整合shiro
安全框架Shiro和Spring Security比较,本文主要围绕Shiro进行学习 一 Shiro 是一个强大而灵活的开源安全框架,能够清晰的处理认证 授权 管理会话以及,密码加密 01 .认证与 ...
- Spring boot整合shiro权限管理
Apache Shiro功能框架: Shiro聚焦与应用程序安全领域的四大基石:认证.授权.会话管理和保密. #,认证,也叫作登录,用于验证用户是不是他自己所说的那个人: #,授权,也就是访问控制,比 ...
- 学习Spring Boot:(十三)配置 Shiro 权限认证
经过前面学习 Apache Shiro ,现在结合 Spring Boot 使用在项目里,进行相关配置. 正文 添加依赖 在 pom.xml 文件中添加 shiro-spring 的依赖: <d ...
- (转)Spring Boot (十四): Spring Boot 整合 Shiro-登录认证和权限管理
http://www.ityouknow.com/springboot/2017/06/26/spring-boot-shiro.html 这篇文章我们来学习如何使用 Spring Boot 集成 A ...
- Spring Boot(十四):spring boot整合shiro-登录认证和权限管理
Spring Boot(十四):spring boot整合shiro-登录认证和权限管理 使用Spring Boot集成Apache Shiro.安全应该是互联网公司的一道生命线,几乎任何的公司都会涉 ...
随机推荐
- wget下载与tar压缩/解压
目录 wget命令 下载整个网站 压缩与解压 小节 wget命令 Usage: wget [OPTION]... [URL]... # 后台运行 -b, --background go to back ...
- linux 能ping通IP但无法解析域名
vi /etc/nsswitch.conf hosts: files dns networks: files 改成: hosts: files dns wins networks: files 最近碰 ...
- Flyway Validate failed: Migration checksum mismatch for migration version 1.0.0.01 错误
在运行系统的时候出现错误: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ...
- hexo的流程
1.基于node 的npm包管理工具2.npm install -g hexo(hexo-cli)3.下载的资源是国外的可能比较慢,可以使用淘宝镜像(代理的仓库)npm install -g hexo ...
- sqli-labs(40)
0X01同样是构造闭合 这里的闭合条件是') 构造语句 ?id=');insert into users values(100,'tx','tx')%23 在客户端mysql里面看看 嘿嘿 成功执行 ...
- mysql 判断时间 语法
今天 select * from 表名 where to_days(时间字段名) = to_days(now()); 昨天 SELECT * FROM 表名 WHERE TO_DAYS( NOW ...
- Docker入门-介绍和安装
Docker容器 Docker是什么 Docker最初是dotCloud公司创建人Solomon Hykes在法国期间发起的一个公司内部项目,它是基于dotCloud公司多年云服务技术的一次革新,并于 ...
- vue项目内嵌入到app input type=file 坑(文件上传插件)
w问题描述: 我用vue-cli完成的一个移动端项目,内嵌到app当中,用原生的input type=file 来完成文件上传.在安卓下没有问题但是在苹果手机 上传第二次手机就会发生白屏 并无缘无故跳 ...
- 11、kubernetes之dashboard
一.准备dashboard使用的证书 # cd /etc/kubernetes/pki/ pki]# (umask 077; openssl genrsa -out dashboard.key 204 ...
- 一起学vue指令之v-pre
一起学vue指令之v-pre 一起学 vue指令 v-pre 指令可看作标签属性 浏览器解析引擎遇到vue的插值符号时会自动解析,当你想输出不被解析的纯文本时,可以使用v-pre指令. 未使用v-p ...