org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [dx.service.ItemService] found for dependency
2024-10-07 11:56:27
在整合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:初学者记录
最新文章
- your local repository contains non-ascii
- 邻接表无向图(二)之 C++详解
- 【代码笔记】iOS-改变文字输入框背景
- 从DACPAC文件中读取元数据
- JS实现图片上传预览效果:方法一
- caffe 训练时,出现错误:Check failed: error == cudaSuccess (4 vs. 0) unspecified launch failure
- ABBYY FineReader 12最新官方版下载
- Sprint计划会议1
- Linux内核通杀提权漏洞CVE-2016-5195验证
- 一些纯css3写的公司logo
- failback 和failover
- 四、Linux/UNIX操作命令积累【chmod、chown、tail】
- 《连载 | 物联网框架ServerSuperIO教程》- 15.数据持久化接口的使用。附:3.2发布与版本更新说明。
- hdu 5288||2015多校联合第一场1001题
- C#编写影院售票系统(A project with a higher amount of gold )
- linux下Tab及shell 补全python
- MTK 快速开机 技术详解
- 移动web前端开发时注意事项(转)
- Python开发系列
- jsp关闭或刷新浏览器(解决浏览器不兼容),请求后台onbeforeunload、onunload
热门文章
- Java——API文档
- springboot-mybatis-demo遇到的坑
- R 保存图片——tiff
- Internet History, Technology, and Security(week4)——History: Commercialization and Growth
- PC端无论页面有没有完全撑开把footer保持在最底部(不用定位)
- Quadratic equation
- debugfs linux rm 删除 恢复 Attempt to read block from filesystem resulted in short read while opening filesystem
- Ajax的封装。
- js将html转换为纯文本
- RNN系列