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


  搭了一个简单的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中添加。

  启动成功。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



猜您在找 Caused by:org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type "" available: expected at least 1 bean which qualifies as autowire candidate 解决 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type的问题 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 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException 错误之Request processing failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined 报错!!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined 多个@bean无法通过@resource注入对应的bean(org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected single matching bean but found )
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM