@Qualifier

@Qualifier可缩小注解范围,也可指定唯一的bean。

package com.imooc.beanannotation.multibean;import java.util.List;
import java.util.Map;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;@Component
public class BeanInvoker {@Autowiredprivate List<BeanInterface> list;@Autowiredprivate Map<String,BeanInterface> map;@Autowired@Qualifier("beanImplOne")private BeanInterface beanInterface;public void say(){if(null!=list&&0!=list.size()){System.out.println("list.");for(BeanInterface bean:list){System.out.println(bean.getClass().getName());}}else{System.out.println("List<BeanInterface> list is null");}System.out.println();if(null!=map&&0!=map.size()){System.out.println("map.");for(Map.Entry<String,BeanInterface> entry:map.entrySet()){System.out.println(entry.getKey()+"   "+entry.getValue().getClass().getName());}}else{System.out.println("Map<String,BeanInterface> is null");}System.out.println();if(null!=beanInterface){System.out.println(beanInterface.getClass().getName());//getClass().getName()是用来返回Class对象所代表的具体对象的名称。}else{System.out.println("beanInterface is null");}}}

运行结果:

观看慕课moocer老师视频Spring Bean装配之Autowire注解说明-3相关推荐

  1. 观看慕课moocer老师视频Spring Bean装配之Autowire注解说明-7

    基于泛型自动装配: package com.imooc.beanannotation.javabased;import org.springframework.beans.factory.annota ...

  2. 观看慕课moocer老师视频Spring Bean装配之Autowire注解说明-2

    数组及Map的自动注入: 1.@controller 控制器(注入服务) 2.@service 服务(注入dao) 3.@repository dao(实现dao访问) 4.@component (把 ...

  3. 观看慕课moocer老师视频Spring Bean装配之Autowire注解说明-6

    默认@Bean是单例的,使用@Scope指定它的范围: package com.imooc.beanannotation.javabased;//import org.springframework. ...

  4. 观看慕课moocer老师视频Spring Bean装配之Autowire注解说明-5

    使用@ImportResource和@Value注解进行资源文件读取 package com.imooc.beanannotation.javabased;import org.springframe ...

  5. 观看慕课moocer老师视频Spring Bean装配之Autowire注解说明-8

    注解在set方法上: package com.imooc.beanannotation.jsr;import javax.annotation.Resource;import org.springfr ...

  6. 观看慕课moocer老师视频Spring Bean装配之Autowire注解说明-1

    @Autowired(放在成员变量上) package com.imooc.test.beanannotation;import org.junit.Test; import org.junit.ru ...

  7. 观看慕课moocer老师视频配置切面aspcet及配置切入点Pointcut

    配置切面: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http:// ...

  8. 观看慕课moocer老师视频AOP基本概念及特点

  9. Spring Bean装配(上)

    Bean:在spring的IOC里面,把配置到IOC容器里面的实体或者是对象都称为Bean Bean配置项 Bean的作用域 Bean的生命周期 Bean的自动装配 Resources&Res ...

最新文章

  1. python培训好学吗-Python0基础好学吗?
  2. C语言实例第5期:在控制台打印100-200之间的所有素数
  3. note同步不及时 one_朱海舟回应锤子便签同步不及时:工程师已经解决
  4. 企业如何用CRM软件客户管理自动化优化流程?
  5. Linux kill 杀死指定进程
  6. cannot instantiate the type
  7. Java Nested Classes(内部类~第一篇英文技术文档翻译)
  8. python编程示例_Python套接字编程–服务器,客户端示例
  9. 360浏览器:中国为什么没有自主研发的浏览器内核?
  10. VMware15pro安装Windows7虚拟机详细教程
  11. yii2设置session时间_YII2 设置session过期时间
  12. ERR_BLOCKED_BY_CLIENT - 请求被广告拦截插件拦截
  13. 富士施乐3065扫描教程_富士施乐打印机3065怎么连接电脑扫描
  14. 技嘉 AORUS RTX2080显卡光线追踪技术详解
  15. 软件开发中的时区问题
  16. 卷积神经网络(CNN)详解
  17. Javaweb实现登录界面“记住我”功能
  18. 空间几何(点线面)知识整理
  19. 云计算 | Gartner最新IaaS魔力象限详读
  20. 区块链之一 起源思想和本质

热门文章

  1. Android深入理解文字绘制:FontMetrics字体测量及其TextPaint介绍
  2. delphi 中 delete的用法
  3. MyEclipse攻略大全
  4. 小猫爪:S32K3学习笔记20:S32K3之SCST及其应用
  5. 比较multiprocessing和subprocess模块
  6. 程序员适不适合创业,无脑崇拜要不得
  7. 写一个函数实现对数字数组的排序
  8. matlab对多元函数求导,MATLAB多元函数导数求极值或最优值Word版
  9. web安全学习神器——DVWA安装部署
  10. 奶茶店小票代码java_由奶茶店突发奇想开始了Java设计模式:享元模式