No qualifying bean of type 问题常见解决方法(SSM项目)

SSM项目No qualifying bean of type 问题常见解决方法

错误信息如下

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.resume.service.impl.UserServiceImpl' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}

常见解决方法:

  1. 检查spring核心配置文件是否扫描了当前类所在的包在这里插入图片描述
  2. 当前类是否有 @Service @Component等注解,当前类是否被@Bean初始化
  3. ssm项目检查是否web.xml配置文件是否有关联spring核心配置文件
    解决方法:在web.xml中添加监听器并且声明应用范围(整个WEB项目)内的上下文初始化参数。代码如下
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值