shiro使用报错---One or more realms must be present to execute an authentication attempt.

使用shiro报错--One or more realms must be present to execute an authentication attempt. One or more realms must be present to execute an authentication attempt.

     必须存在一个或多个领域执行身份验证。必须存在一个或多个领域执行身份验证。

       在配置SecurityManager的bean的时候,没有设置Realm域

@Bean
    public SecurityManager securityManager(){
        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
        //设置realm,这里不设置的话会报错
        //One or more realms must be present to execute an authentication attempt. One or more realms must be present to execute an authentication attempt.
        securityManager.setRealm(myShiroRealm());
        return securityManager;
    }

如果是xml文件配置,就是没有注入自定义的Realm域的属性。

猜你喜欢

转载自blog.csdn.net/kaola_l/article/details/80239395