shiro错误 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
来源:互联网 发布:c语言字符串指针传递 编辑:程序博客网 时间:2024/06/06 04:37
最近在弄个小模块,用的是spring mvc + mybites + spring shiro
在弄shiro 的Realm自动注入的时候总是报错,
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.sam.project.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:618)
... 44 more
纠结许久,终于在网上查询到了解决方案
Shiro的Realm 是属于Filte,因此在web.xml里面加载的时候会先加载Filete,然后才加载到Spring,所以Realm中@Autowired总是找不到bean,其实容器启动后,web.xml的配置加载顺序是
ServletContext--context-param--listener--filter--servlet
因此,只要把Spring配置文件提前加载即可,即:在web.xml中把spring配置文件放在Shiro配置文件之前,如下图:
按照上面的配置修改后,重启服务即可!
其他的注入配置不变,不需要设置什么@Resource,还是用之前的@Autowired。
- shiro错误 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.act
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.wei
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [cn.itca
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.cui
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.lin
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type
- Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of ty
- Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of ty
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.hiber
- Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.serv
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.yuanv.b
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean nam
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named is defined
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager'
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'xxxxx' i
- ieda 怎么解决引入版本过多导致的no class found(因为它蒙圈了)
- 如何使用特定显卡跑tensorflow
- 欢迎使用CSDN-markdown编辑器
- 解决Git Http方式 push pull 重复输入用户名和密码问题
- P1349 广义斐波那契数列
- shiro错误 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
- =和==的陷阱,我的坑
- mybatis 笔记1 为什么需要mybatis
- 递归小例子
- android dialog用法总结
- UPC 2017 Summer Training 5
- sql 递归查询分类树列表with as
- 链表的基本操作
- python命令行参数解析模块argparse和docopt