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类

      想到再补充吧

    
    
    
    
  • 相关阅读:
    DHCP分配ip地址。0.0.0.0与255.255.255.255
    net-snmp配置文件详解
    net-snmp开发中出现“Error opening specified endpoint"" ”的解决方案
    Elasticsearch 学习笔记
    Prometheus 监控报警系统 AlertManager 之邮件告警
    Match All Query
    Elasticsearch postman
    Centos7修改root密码
    ElasticSearch中profile API的使用
    kafka查询某时间段内的消息
  • 原文地址:https://www.cnblogs.com/oldzhang1222/p/7988814.html
Copyright © 2011-2022 走看看