本文主要是介绍NoSuchBeanDefinitionException: No qualifying bean of type xx,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
zhu失败,找不到具体对象
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'xxx.xxx.xxx' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1509)at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065)at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584)
注入失败:
1.常见的有没加注解或包扫描,加上便是。
2.这次是一个小细节,在加载applicationContext文件时classpath后面要加上一个*号,防止jar包里的配置文件引入不到
如:
<context-param><param-name>contextConfigLocation</param-name><param-value>classpath*:applicationContext*.xml</param-value></context-param>
这篇关于NoSuchBeanDefinitionException: No qualifying bean of type xx的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!