微服务使用Shiro 框架时 SecurityUtils.getSubject() 时报错 :org.apache.shiro.UnavailableSecurityManagerException

异常信息:

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.

原因:

我自身的原因,是因为在微服务中,把shiro配置文件只是放在了用户服务中,别的服务没有,而我又配置了redis 服务器用于 shiro的 SessionId 共享(由于从redis中取sessionId需要对配置文件进行redis 与shiro的整合配置)所以当我访问到没有shiro配置文件的服务时,则会报出该异常。

解决方案:

将shiro的配置文件放入当前访问的服务中即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章