Shrio 多realms集成:No realms have been configured! One or more realms must be present
来源:互联网 发布:mac南瓜色口红是几号 编辑:程序博客网 时间:2024/05/29 16:14
我用springboot在代码中集成多realms的时候一直遇到这个异常。
代码如下:
@Bean public SecurityManager securityManager(){ DefaultWebSecurityManager securityManager=new DefaultWebSecurityManager(); //设置realm. List<Realm> realms=new ArrayList<>(); realms.add(myShiroRealm()); realms.add(myShiroRealm2()); securityManager.setRealms(realms); securityManager.setAuthenticator(modularRealmAuthenticator()); return securityManager; }
这里有提供realms的set方法,所以肯定是支持多realms的。
后来把modularRealmAuthenticator这块代码放到了前面就好了。
@Bean public SecurityManager securityManager(){ DefaultWebSecurityManager securityManager=new DefaultWebSecurityManager(); //设置realm. securityManager.setAuthenticator(modularRealmAuthenticator()); List<Realm> realms=new ArrayList<>(); realms.add(myShiroRealm()); realms.add(myShiroRealm2()); securityManager.setRealms(realms); return securityManager; }
很狗血的问题。
猜测可能是要先设置多realm管理器modularRealmAuthenticator,然后在设置realm,才能把realm设置进modularRealmAuthenticator。如果设置的晚了,可能就无法加载realm了。
阅读全文
0 0
- Shrio 多realms集成:No realms have been configured! One or more realms must be present
- shiro使用报错---One or more realms must be present to execute an authentication attempt.
- shiro中出现Caused by: java.lang.IllegalStateException: Configuration error: No realms have been config
- Apache Shiro Realms
- Shiro自定义Realms
- 第六章:Shiro的Realms
- Armadillo v4.44b by Silicon Realms
- Realms Of Joy - Time Of Light.
- 【Shiro权限管理】13. SecurityManager配置realms
- 关于vc调试出现One or more breakpoints cannot be set and have been disabled解决方法。
- 烦人的 One or more breakpoints cannot be set and have been disabled.……
- 关于vc调试出现One or more breakpoints cannot be set and have been disabled解决方法
- 于vc调试出现One or more breakpoints cannot be set and have been disabled
- (zz)(VC 6++) One or more breakpoints cannot be set and have been disabled
- 关于vc调试出现One or more breakpoints cannot be set and have been disabled解决方法
- 关于vc调试出现One or more breakpoints cannot be set and have been disabled
- 关于vc调试出现One or more breakpoints cannot be set and have been disabled解决方法
- One or more breakpoints cannot be set and have been disabled
- ubuntu python lxml安装
- angular简介
- 数据结构实验之图论二:图的深度遍历
- 安装类型文件
- 理解容器之间的连通性(涉及iptables、router、ip forwarding)
- Shrio 多realms集成:No realms have been configured! One or more realms must be present
- 批处理文件.bat中echo off和echo on的作用
- 什么是spa
- 使用PhotoSwipe-master实现相册功能
- BigDecimal add方法问题:调用add后,求和结果没变
- angular 程序组成
- CentOS7 64位下MySQL5.7安装与配置(YUM)
- seo必备的关键词策略
- 数据库通过文件导入数据