Consider defining a bean named ‘shiroFilterFactoryBean‘ in your configuration.

springboot整合shiro时报错:

 ERROR 21620 --- 
[  restartedMain] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. 
Message: Error creating bean with name 'filterShiroFilterRegistrationBean' defined in class path resource 
[org/apache/shiro/spring/config/web/autoconfigure/ShiroWebFilterConfiguration.class]:
 Bean instantiation via factory method failed;
  nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]:
Factory method 'filterShiroFilterRegistrationBean' threw exception;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No bean named 'shiroFilterFactoryBean' available
-----
  WARN 21620 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat

主要就是这两句话:
Method filterShiroFilterRegistrationBean in org.apache.shiro.spring.config.web.autoconfigure.ShiroWebFilterConfiguration required a bean named ‘shiroFilterFactoryBean’ that could not be found.

Action:

Consider defining a bean named ‘shiroFilterFactoryBean’ in your configuration.


一开始我也想了一会儿,实在感觉也没错啊,不过,按照它说的这个“缺少shiroFilterFactoryBean”,有点纳闷。后面仔细一比较,我发现这个bean是首字母小写的,不是“ShiroFilterFactoryBean”这个类,这样的话就简单了:
只要把在@Bean前面+这个name就可以了。

@Bean(name = "shiroFilterFactoryBean")
    public ShiroFilterFactoryBean shiroFilter(@Qualifier("mySecurityManager") 
			DefaultWebSecurityManager securityManager) {

还有一种办法就是在写方法名的时候命名为:getShiroFilterFactoryBean,这样的话也可以运行的。


总结

这次,我只能说就是我的基础不好。哎,以前学Spring的时候,花了不少时间,但是效果很不理想,主要是学的时候操作太少了。比较懒,<bean>标签等等,我没有弄明白原理,或者说后面又忘记了,当时的笔记也没有做好(这里我得说,做笔记、如何做笔记真的是很重要),当时我就看到视频里的老师有笔记,就没想自己写笔记了,现在看来后悔了!还有,编程做笔记尽量用typora,毕竟这个看起来确实是最舒服的了!

  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值