使用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域的属性。
本文介绍了解决Shiro框架中出现的身份验证错误的具体方法。主要原因是未正确配置SecurityManager中的Realm域,通过示例代码展示了如何在Java配置中设置自定义Realm。
2851

被折叠的 条评论
为什么被折叠?



