Appeared when testing Shiro framework
Configuration error: No realms have been configured! One or more realms must be present to execute an authentication attempt.
It probably means: Configuration error: No realm is configured! One or more domains must exist to perform an authentication attempt.
After looking for a long time, some on the Internet say yes
<property name="realms">与<property name="authenticator" ref="authenticator" />
Wrong order
But it didn't solve
Finally found
@Bean
public DefaultWebSecurityManager getDefaultWebSecurityManager(@Qualifier("userRealm") UserRealm userRealm){
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
//Associate UserRealm, UserRealm cannot be obtained directly at this time, skills are required
securityManager.setRealm(userRealm);
return new DefaultWebSecurityManager();
}
When returning the object, I made a new new
by mistake, and did not return the object passed in userRealm