本篇主要介绍一下@Resource、@Autowired、@Qualify、@Value的注解的的用法以及XML配置包扫描的方法。https://gitee.com/gao_xi/spring-demo1/tree/component-scan/
1.@AutoWired和@Qualifier(“xxx”)
- 纯@AutoWired用法
- 使用byType的注入方式
 
 组合使用的方式
纯@Rsource注解
- byName -> byType
 - byName -> 依据变量名称来进行
 - byName找到后立刻停止查找,容易报类型不匹配异常
 
- 添加name属性@Resource(name=”xx”)
- 只会byName寻找,找不到就报异常
 
 - 添加type属性@Resource(type=xxx)
- 还是会先根据变量名进行byName
 
 全属性 @Resource(name=””,type=)
<!--禁用默认的扫描过滤器配置--><context:component-scan base-package="com.gao" use-default-filters="false"><context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan><context:component-scan base-package="com.gao"><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan>
