org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [dx.service.ItemService] found for dependency
在整合ssm框架,测试service层的时候报错
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [dx.service.ItemService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1308)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1054)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:949)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:530)
... 27 more org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Test.ItemServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private dx.service.ItemService Test.ItemServiceTest.itemService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [dx.service.ItemService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
这里是service依赖注入失败,后来发现在applicationContext.xml要配置
<context:annotation-config />
<context:component-scan base-package="dx.service" />
springmvc.xml里面也要配置
<!-- 扫描@Controler @Service -->
<context:component-scan base-package="dx"/>
然后问题就解决了。
ps:初学者记录
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [dx.service.ItemService] found for dependency的更多相关文章
- 添加事务后 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type available
今天遇到了一个奇怪的问题 在没添加事务之前 所有的代码都是好的 , 当我添加了事务之后, 代码报错 org.springframework.beans.factory.NoSuchBeanDef ...
- spring Boot异步操作报错误: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.self.spring.springboot.Jeep' available
我也是最近开始学习Spring Boot,在执行异步操作的时候总是汇报如下的错误: Exception in thread "main" org.springframework.b ...
- Caused by:org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type "" available: expected at least 1 bean which qualifies as autowire candidate
项目使用spring, mybatis.因为分了多个模块,所以会这个模块引用了其它模块的现在,结果使用Junit测试的时候发现有两个模块不能自动注入dao和service问题.解决后在此记录一下. 解 ...
- 解决 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type的问题
具体错误如下: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying be ...
- Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.qingmu.mybaitsplus.mapper.UserMapper' available:
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.conte ...
- springboot 报错 org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'com.example.service.HrService' available: 有没有大佬出个主意,我找了一天,刚入门springboot
话不多说先上图,这是启动类的配置,这里配置了@ComponentScan("我的mapper的接口") 接下来是我的项目结构截图 然后是service 的截图,我在这里加了注解@S ...
- springboot启动报错:Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.zxkj.lockserver.dao.CompanyDao' available: expected at least 1 bean which qua
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of ty ...
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.oskyhang.gbd.service.UserService] found for dependency: expected at least 1 bean which qualifies as aut
spring中一个符号的错误居然让我浪费了四五个小时才找出来,不得不给自己了两个耳光.. 由于新建项目与原来项目的目录结构有所不同,copy过来的配置文件,有些地方修改的不彻底,导致spring扫描注 ...
- Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.thinkplatform.dao.UserLogDao' available: expected at least 1 bean which qualifies as autowi
我出错的问题是: 检查:
随机推荐
- 使用穷举法结合numpy解决八皇后问题
一般说到八皇后问题,最先想到的就是回溯思想,而回溯思想往往是需要递归来实现的. 计算机很善长做重复的事情,所以递归正和它的胃口,而我们人脑更喜观平铺直叙的思维方式.当 我们看到递归时,总想把递归平铺展 ...
- Navicat 出现的[Err] 1146 - Table 'performance_schema.session_status' doesn't exist已解决
[Err] 1146 - Table 'performance_schema.session_status' doesn't exist已解决 刚刚接触MySQL,就往数据库添加数据,就遇到这个问 ...
- USACO2018 DEC (Gold) (dp,容斥+哈希,最短路)
\(T1\) 传送门 解题思路 傻逼\(dp\)..直接\(ST\)表处理最大值\(O(n^2)\)艹过了. 代码 #include<bits/stdc++.h> using namesp ...
- RabbitMQ消费端自定义监听(九)
场景: 我们一般在代码中编写while循环,进行consumer.nextDelivery方法进行获取下一条消息,然后进行消费处理. 实际环境: 我们使用自定义的Consumer更加的方便,解耦性更强 ...
- [CSP-S模拟测试]:连连看(图论+容斥)
题目传送门(内部题74) 输入格式 输入文件$link.in$ 第一行三个整数$n,m,k$,之间用空格隔开,$n,m$表示地图行数和列数,$k$表示每个方块周围相邻的位置(至多有$4$个,至少有$2 ...
- win7x64 串口程序无法运行,提示:component 'MSCOMM32.OCX' or one of its dependencies not correctlu registered。。。
VB写的串口工具在win7 x64机器运行时遇到的问题, component 'MSCOMM32.OCX' or one of its dependencies not correctlu regis ...
- 使用JS将图片转为Base64
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- leetcode-mid-array-31 three sum-NO
my code: time limited def threeSum(nums): """ :type nums: List[int] :rtype: List[L ...
- 【洛谷T2695 桶哥的问题——吃桶】
这是我们团队的一个题目(就是一个_rqy说很好写的题QwQ) 题目背景 @桶哥 这个题目的思路很玄学(性感_rqy在线讲解) 60 Pts 对于前面的六十分,好像很好拿,单纯的打一个模拟 唯一需要注意 ...
- CopyOnWriteArrayList 源码分析
CopyOnWriteArrayList CopyOnWriteArrayList 能解决什么问题?什么时候使用 CopyOnWriteArrayList? 1)CopyOnWriteArrayLis ...