【SpringBoot已解决】SpringBoot整合shiro,DefaultWebSecurityManager和DefaultSecurityManager使用不当出现报错

介绍

这里是小编成长之路的历程,也是小编的学习之路。希望和各位大佬们一起成长!

以下为小编最喜欢的两句话:

要有最朴素的生活和最遥远的梦想,即使明天天寒地冻,山高水远,路远马亡。

一个人为什么要努力? 我见过最好的答案就是:因为我喜欢的东西都很贵,我想去的地方都很远,我爱的人超完美。因此,小编想说:共勉! 


目录

前言

第一个问题:

第二个问题:

第三个问题:

第四个问题:


第一个问题:

Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException:等等

第二个问题:

Error creating bean with name 'getShiroFilterFactoryBean' defined in class path resource [com/lyn/config/ShiroConfig.class]: Unsatisfied dependency expressed through method 'getShiroFilterFactoryBean' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.shiro.web.mgt.DefaultWebSecurityManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=securityManager)}

第三个问题:

No qualifying bean of type 'org.apache.shiro.web.mgt.DefaultWebSecurityManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=securityManager)}

第四个问题:

The security manager does not implement the WebSecurityManager interface.

 

出现以上的问题都是DefaultWebSecurityManager和DefaultSecurityManager的使用不当的问题

如果出现上述问题查看是否是DefaultWebSecurityManager和DefaultSecurityManager使用不当所报的错误

错误代码:

    @Bean(name ="securityManager")
    public DefaultSecurityManager getDefaultWebSecurityManager(@Qualifier("userRealm") UserRealm userRealm) {
        DefaultSecurityManager securityManager= new DefaultSecurityManager();
        //关联realm
        securityManager.setRealm(userRealm);
        return securityManager;
    }

正确代码:

@Bean(name ="securityManager")
    public DefaultWebSecurityManager getDefaultWebSecurityManager(@Qualifier("userRealm") UserRealm userRealm) {
        DefaultWebSecurityManager securityManager= new DefaultWebSecurityManager();
        //关联realm
        securityManager.setRealm(userRealm);
        return securityManager;
    }

以上就是小编出现的问题,以及解决方法,感谢各位大佬的观看!!!

猜你喜欢

转载自blog.csdn.net/weixin_60387745/article/details/129267580