【发布时间】:2021-02-10 10:44:03
【问题描述】:
如题,我在Shiro管理的Springboot项目中开发WebSocket时,需要在socket接口中获取当前登录用户的信息
public static Subject getSubjct() {
return SecurityUtils.getSubject();
}
这一行出错:SecurityUtils.getSubject();
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)
at com.runtime.system.util.ShiroUtils.getSubjct(ShiroUtils.java:18)
at com.runtime.system.util.ShiroUtils.getUser(ShiroUtils.java:22)
常规的Api接口不存在这个问题。我感到非常苦恼。请帮帮我,谢谢!
【问题讨论】: