zoukankan      html  css  js  c++  java
  • <context annotation-config />标签意义

    该标签隐式的向Spring容器注册了:
      AutowiredAnnotationBeanPostProcessor
      CommondAnnotationBeanPostProcessor
      PersistenceAnnotationBeanPostProcessor
      RequiredAnnotationBeanPostProcessor
    这四个BeanPostProcessor.

     
    1.AutowiredAnnotationBeanPostProcessor:主要是使用@AutoWired注解时,必须提前向Spring容器注册这个BeanPostprocessor
    传统的配置方式:<bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>
     
    2.CommondAnnotationBeanPostprocessor:主要是使用@Resource、@PostConstruct、@Predestory等注解时,必须提前向Spring容器注册。
    传统配置方式:<bean class="org.springframework.beans.factory.annotation.CommondAnnotationBeanPostprocessor"/>
     
    3.PersistenceAnnotationBeanPostProcessor :主要是使用@PersistenceContext注解时,必须提前向Spring容器注册。
    传统配置方式:<bean class="org.springframework.beans.factory.annotation.PersistenceAnnotationBeanPostProcessor"/>
     
    4.RequiredAnnotationBeanPostProcessor:主要是使用@Required注解时,必须提前向Spring容器注册。
    传统配置方式:<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
     
    一般来说,@Autowired注解比较常用,传统配置方式有点繁琐,而这种隐式配置方式就可以帮我们很容易的搞定。
    不过使用注解,我们一般都会配置扫描包路径:<context: component-scan base-package=com.xxx.xxx />
    其实,给配置已经包含了自动注入上述Processor的功能,所以,配置了包扫描之后,<context annotation-config />就可以移除了。
     

    QQ技术交流群:576269252

    --------------------------------------

    声明: 原创文章,未经允许,禁止转载!

    --------------------------------------

  • 相关阅读:
    【原】基础篇:第一篇,本节主要向大家介绍Ext的最基础的话题
    【原】基础篇:第七篇,Ext组件系列之label组件的基本用法
    【原】基础篇:第三篇,常用的一些Ext方法
    框架
    【原】基础篇:第六篇,Ext组件系列之button组件的基本用法
    序列化
    【原】基础篇:第四篇,Ext中有两个很重要的方法,一个是decode;一个是encode.
    Arrays.asList详解
    JSP页面导出CSV查询结果
    Log的重要性
  • 原文地址:https://www.cnblogs.com/xxoome/p/6743299.html
Copyright © 2011-2022 走看看