Tag Archives: Configuration error: No realms have been configured! One or more realms must be present to execute an authentication attempt.

Configuration error: No realms have been configured! One or more realms must be present to execute an authentication attempt.

There was a problem testing the Shiro framework

Configuration error: No realms have been configured! One or more realms must be present to execute an authentication attempt.

Configuration error: no fields are configured! One or more domains must exist to perform authentication attempts.

I’ve been looking for it for a long time. Some people on the Internet say yes

<property name="realms"> or <property name="authenticator" ref="authenticator" />

Wrong order

But not solved

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 the object is returned, a new one is created incorrectly, and the object passed into user realm is not returned