码迷,mamicode.com
首页 > 编程语言 > 详细

org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'xxx 'available

时间:2019-02-17 23:34:22      阅读:326      评论:0      收藏:0      [点我收藏+]

标签:dep   class   can   user   ann   contex   red   tor   init   

  搭了一个简单的SSM项目,启动报错:

  org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type ‘com.xxx.ssmdemo.service.IUserService‘ available: expected at least 1 bean

  which qualifies as autowire candidate.Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

  提示很清楚,找不到IUserService这个Bean的定义,所以自动注入出错。那么找不到Bean,可能有两种情况,一是真的没有定义这个接口(不太可能),二就是Spring没有扫描到相关的类或者接口。

  原因:项目中有spring-mvc.xml,spring-mybatis.xml,applicationContext.xml共三个配置文件。而我在前两个配置文件中都添加了<context : compoment-scan>,在applicationContext.xml中却没有配。

  解决:将其余配置文件中的<context : compoment-scan>删除,在applicationContext中添加。

  启动成功。

 

org.springframework.beans.factory.NoSuchBeanDefinitionException:

No qualifying bean of type ‘com.sitech.ssmdemo.service.IUserService‘ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'xxx 'available

标签:dep   class   can   user   ann   contex   red   tor   init   

原文地址:https://www.cnblogs.com/Ezi0/p/10392426.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!