spring自动装配(No qualifying bean )

No qualifying bean of type [com.wfj.service.cms.main.ChannelMng] 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)}

1、检查注解引入的包是否正确,一般为(org.springframework.stereotype.*){service,controller,responsity,repository}

2、扫描包没扫描上(配置文件base-package配置出现异常)

eg:

<mvc:annotation-driven />//扫描组件
<context:component-scan base-package="com.sun.test.aircraft.controller" use-default-filters="false"><!-- base-package 如果多个,用“,”分隔 -->
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
扫描com.sun.test.aircraft.controller包下的注解(base-package配置的是最终的包路径,该包下使用的@Service,@Autowired,@Controller 等注解都会扫描到)
这种写法对于include-filter来讲它都会扫描,而不是仅仅扫描@Controller

此文章观点可能有误,若理解有偏差,请参考其他博主文章(此文章是我当时做案例时以配置bean的方式脑子里想的注解的方式做的测试,后来发现出错了并不是我想的那样, 所以此文章暂时不做参考)
原文地址:https://www.cnblogs.com/austinspark-jessylu/p/7705015.html