Configuration error: No realms have been configured! One or more realms must be present to execute an authentication attempt.
测试Shiro框架时候出现了
Configuration error: No realms have been configured! One or more realms must be present to execute an authentication attempt.
大概意思是:配置错误:未配置任何领域!必须存在一个或多个域才能执行身份验证尝试。
找了好久,网上有的说是
<property name="realms">与<property name="authenticator" ref="authenticator" />
顺序错了
但是没解决
最后发现
@Bean
public DefaultWebSecurityManager getDefaultWebSecurityManager(@Qualifier("userRealm") UserRealm userRealm){
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
//关联UserRealm,此时不能直接获取UserRealm,需要技巧
securityManager.setRealm(userRealm);
return new DefaultWebSecurityManager();
}
返回对象时候,错误的重新new了一个,没有将传入userRealm的对象返回

浙公网安备 33010602011771号