今天遇到一个shiro的报错:
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:627)
at org.apache.shiro.SecurityUtils.getSubject(SecurityUtils.java:56)
at com.len.base.impl.BaseServiceImpl.addValue(BaseServiceImpl.java:87)
at com.len.base.impl.BaseServiceImpl.insert(BaseServiceImpl.java:75)
at com.XXXXXXXXXXX.service.impl.XXXXXXXXXXXImpl.insert(XXXXXXXXXXXImpl.java:13)
这块逻辑是对外的接口,首先看了下shiro的配置
确认对外是放行的,但怎么会权限报错呢?
继续分析详细报错
at com.XXXXXXXXXXX.service.impl.XXXXXXXXXXXImpl.insert(XXXXXXXXXXXImpl.java:13)
这块是我对返回信息进行入库处理,注意这块用的是框架封装的方法!类似于BaseMapper肯定是那块配置做了校验,
解决方法:简单处理,手写一个Mapper插入方法即可;
成功