场景
* 在spring boot +spring shiro * 自定义filter的拦截器 并从doFilter中调用 SecurityUtils.getSubject().getPrincipal() * 抛出 * 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.
解决方案
@Bean(“shiroFilter”) public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) { … }
- 注意!上图是关键 (相当于web.xml中定义shiro的执行顺序)