junit 测试 shiro 方法 报错 UnavailableSecurityManagerException: No SecurityManager accessible to .....

1.在测试的类中注入 SecurityManager 

@Resource

org.apache.shiro.mgt.SecurityManager securityManager;

2. @Before   时 绑定  securityManager


参考  https://www.oschina.net/question/4934_48690


@Resource

    org.apache.shiro.mgt.SecurityManager securityManager;

    @Before

    public void setUp() throws Exception {

        ThreadContext.bind(securityManager);

    }


猜你喜欢

转载自blog.csdn.net/HK2311/article/details/80608916