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的方式脑子里想的注解的方式做的测试,后来发现出错了并不是我想的那样, 所以此文章暂时不做参考)
spring自动装配(No qualifying bean )的更多相关文章
- Spring 自动装配 Bean
Spring3系列8- Spring 自动装配 Bean 1. Auto-Wiring ‘no’ 2. Auto-Wiring ‘byName’ 3. Auto-Wiri ...
- Spring自动装配Bean详解
1. Auto-Wiring ‘no’ 2. Auto-Wiring ‘byName’ 3. Auto-Wiring ‘byType 4. Auto-Wirin ...
- Spring自动装配歧义性笔记
Spring自动装配歧义性笔记 如果系统中存在两个都实现了同一接口的类,Spring在进行@Autowired自动装配的时候,会选择哪一个?如下: // 一下两个类均被标记为bean @Compone ...
- spring 自动装配 default-autowire="byName/byType"
<PRE class=html name="code">spring 自动装配 default-autowire="byName/byType" ...
- Spring自动装配Beans
在Spring框架,可以用 auto-wiring 功能会自动装配Bean.要启用它,只需要在 <bean>定义“autowire”属性. <bean id="custom ...
- Spring自动装配----注解装配----Spring自带的@Autowired注解
Spring自动装配----注解装配----Spring自带的@Autowired注解 父类 package cn.ychx; public interface Person { public voi ...
- Spring系列七:Spring 自动装配
相思相见知何日?此时此夜难为情. 概述 在Spring框架中,在配置文件中声明bean的依赖关系是一个很好的做法,因为Spring容器能够自动装配协作bean之间的关系.这称为spring自动装配. ...
- Spring自动装配之依赖注入(DI)
依赖注入发生的时间 当Spring IOC 容器完成了Bean 定义资源的定位.载入和解析注册以后,IOC 容器中已经管理类Bean定义的相关数据,但是此时IOC 容器还没有对所管理的Bean 进行依 ...
- Spring自动装配(二)
为什么Spring要支持Autowire(自动装配) 先写几个类,首先定义一个Animal接口表示动物: 1 public interface Animal { 2 3 public void eat ...
随机推荐
- 导入android源码中的APP源码到eclipse
导入android源码中的APP源码到eclipse 一般最简单的办法就是创建新的android工程,选择create project from existing source选项,直接导入源码就OK ...
- SQL的主键和外键的作用
SQL的主键和外键约束 转载自:http://www.cnblogs.com/ywb-lv/archive/2012/03/12/2391860.html感谢原文作者的总结 SQL的主键和外键的作用: ...
- python类中两个列表实例如何相加或相减
如下 import numpy a = [1, 2, 3, 4] b = [5, 6, 7, 8] a_array = numpy.array(a) b_array = numpy.array(b) ...
- (二十五)epoll深入理解续
转自:http://blog.csdn.net/yusiguyuan/article/details/15027821 在Linux的网络编程中,很长的时间都在使用select来做事件触发.在linu ...
- (二十二)函数fseek() 用法
fseek 函数名: fseek功 能: 重定位流上的文件指针用 法: int fseek(FILE *stream, long offset, int fromwhere);描 述: 函数设置文件指 ...
- mysql 主从手动切换
将主从(3307主--3308从)切换 前提:3307正常 一.将3307设为只读.命令行操作 # 修改配置文件 vim /etc/mysql/mysql-//my.cnf # 在[mysqld]中增 ...
- cmake add_executable 与 include_directories
在cmake里add_executable里如果没有包含.cpp文件,该.cpp文件就不适用include_directories包含文件
- (29)C#多线程
使用线程的原因 1.不希望用户界面停止响应. 2.所有需要等待的操作,如文件.数据库或网络访问需要一定的时间. 一个进程的多个线程可以同时运行不同cpu或多核cpu的不同内核上 注意多线程访问相同的数 ...
- 华农oj Problem B: Averyboy找密码【STL】
Problem B: Averyboy找密码 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 83 Solved: 29 [Submit][Status] ...
- Codeforces Round #447 (Div. 2) C. Marco and GCD Sequence【构造/GCD】
C. Marco and GCD Sequence time limit per test 1 second memory limit per test 256 megabytes input sta ...