请问报错UnavailableSecurityManagerException是什么回事

来源:3-1 Shiro认证

孙建博

2018-05-15 16:39

在springboot环境下测试的,会报错:

org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton.  This is an invalid application configuration.

at org.apache.shiro.SecurityUtils.getSecurityManager(SecurityUtils.java:123)

at org.apache.shiro.subject.Subject$Builder.<init>(Subject.java:626)

at org.apache.shiro.SecurityUtils.getSubject(SecurityUtils.java:56)


写回答 关注

2回答

  • qq_慕姐7330780
    2022-12-07 00:07:44

    怎么解决的?


  • 孙建博
    2018-05-15 16:47:12

    呃,是自己的失误

    少了一句

    SecurityUtils.setSecurityManager(defaultSecurityManager);


    qq_sil... 回复qq_涳杺_...

    加在 @Bean public SecurityManager getSecurityManager() { DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); SecurityUtils.setSecurityManager(securityManager); return securityManager; }

    2020-03-31 09:40:02

    共 2 条回复 >

Shiro安全框架入门

从零入门Shiro安全框架

48036 学习 · 332 问题

查看课程

相似问题