zoukankan      html  css  js  c++  java
  • context:component-scan标签的诠释

      

      XML中配置context:component-scan时,spring会自动的扫描这个包下被这些注解标识的类@Component,@Service,@Controller,@Repository,同时自动注册为bean

      同时context:component-scan包含了context:annotation-config的属性开关功能

      具体的属性注册四个BeanPostProcessor:

      AutowiredAnnotationBeanPostProcessor、CommonAnnotationBeanPostProcessor、

      PersistenceAnnotationBeanPostProcessor 、RequiredAnnotationBeanPostProcessor。

      AutowiredAnnotationBeanPostProcessor的注册对应使用@Autowired注解,

      CommonAnnotationBeanPostProcessor注册对应使用@ Resource 、@ PostConstruct、@ PreDestroy注解,

      PersistenceAnnotationBeanPostProcessor 注册对应使用@PersistenceContext注解,

      RequiredAnnotationBeanPostProcessor注册对应使用@Required注解。

      由于我们一般使用context:component-scan(包含自动注入上方的四个BeanPostProcessor)功能的注解包的扫描,context:annotation-config的存在基本可以忽略了

      context:component-scan的子标签包含了

            <context:exclude-filter type="" expression=""/>
            <context:include-filter type="" expression=""/>

      context:exclude-filter:告知哪些类或者接口不需要被扫描

      context:include-filter:告知哪些类或者接口需要被扫描,并注册成bean类

      想到再补充吧

    
    
    
    
  • 相关阅读:
    数据结构 链表笔记
    C语言 字符串操作 笔记
    数据结构 排序算法 笔记
    链表详解
    mysql常用命令
    图片压缩工具之grunt-contrib-imagemin
    正则表达式
    阿里云部署nodejs服务器(windows)
    canvas简介
    js面向对象
  • 原文地址:https://www.cnblogs.com/oldzhang1222/p/7988814.html
Copyright © 2011-2022 走看看