在整合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:初学者记录

最新文章

  1. your local repository contains non-ascii
  2. 邻接表无向图(二)之 C++详解
  3. 【代码笔记】iOS-改变文字输入框背景
  4. 从DACPAC文件中读取元数据
  5. JS实现图片上传预览效果:方法一
  6. caffe 训练时,出现错误:Check failed: error == cudaSuccess (4 vs. 0) unspecified launch failure
  7. ABBYY FineReader 12最新官方版下载
  8. Sprint计划会议1
  9. Linux内核通杀提权漏洞CVE-2016-5195验证
  10. 一些纯css3写的公司logo
  11. failback 和failover
  12. 四、Linux/UNIX操作命令积累【chmod、chown、tail】
  13. 《连载 | 物联网框架ServerSuperIO教程》- 15.数据持久化接口的使用。附:3.2发布与版本更新说明。
  14. hdu 5288||2015多校联合第一场1001题
  15. C#编写影院售票系统(A project with a higher amount of gold )
  16. linux下Tab及shell 补全python
  17. MTK 快速开机 技术详解
  18. 移动web前端开发时注意事项(转)
  19. Python开发系列
  20. jsp关闭或刷新浏览器(解决浏览器不兼容),请求后台onbeforeunload、onunload

热门文章

  1. Java——API文档
  2. springboot-mybatis-demo遇到的坑
  3. R 保存图片——tiff
  4. Internet History, Technology, and Security(week4)——History: Commercialization and Growth
  5. PC端无论页面有没有完全撑开把footer保持在最底部(不用定位)
  6. Quadratic equation
  7. debugfs linux rm 删除 恢复 Attempt to read block from filesystem resulted in short read while opening filesystem
  8. Ajax的封装。
  9. js将html转换为纯文本
  10. RNN系列