<context:annotation-config> 是用于激活那些已经在spring容器里注册过的bean上面的注解。该标签主要向容器中掩式定的注了 AutowiredAnnotationBeanPostProcessor  CommondAnnotationBeanPostProcessor  PersistenceAnnotationBeanPostProcessor    RequiredAnnotationBeanPostProcessor这四大组件  

          AutowiredAnnotationBeanPostProcessor:主要是使用@AutoWired注解时,必须提前向Spring容器注册这个BeanPostprocessor
  传统的配置方式:<bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>
          CommondAnnotationBeanPostprocessor:主要是使用@Resource、@PostConstruct、@Predestory等注解时,必须提前向Spring容器注册。
 传统配置方式:<bean class="org.springframework.beans.factory.annotation.CommondAnnotationBeanPostprocessor"/>
          PersistenceAnnotationBeanPostProcessor :主要是使用@PersistenceContext注解时,必须提前向Spring容器注册。
 传统配置方式:<bean class="org.springframework.beans.factory.annotation.PersistenceAnnotationBeanPostProcessor"/>
          RequiredAnnotationBeanPostProcessor:主要是使用@Required注解时,必须提前向Spring容器注册。
 传统配置方式:<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
 

  <context:component-scan>除了具有<context:annotation-config>的功能之外,<context:component-scan>还可以在指定的package下扫描以及注册javabean 。该标签只是向spring容器中注册 AutowiredAnnotationBeanPostProcessor 实例, 该实例可以自动装配具有 @Autowired 和@Resource 、@Inject注解的属性.

  @Service用于标注业务层组件,@Controller用于标注控制层组件(如struts中的action),@Repository用于标注数据访问组件,即DAO组件,而@Component泛指组件,当组件不好归类的时候,我们可以使用这个注解进行标注。

  @Autowired与@Resource都可以用来装配bean。

  

 

spring关于bean的一些配置说明的更多相关文章

  1. Spring中Bean的作用域、生命周期

                                   Bean的作用域.生命周期 Bean的作用域 Spring 3中为Bean定义了5中作用域,分别为singleton(单例).protot ...

  2. Spring中Bean的实例化

                                    Spring中Bean的实例化 在介绍Bean的三种实例化的方式之前,我们首先需要介绍一下什么是Bean,以及Bean的配置方式. 如果 ...

  3. 工厂模式模拟Spring的bean加载过程

    一.前言    在日常的开发过程,经常使用或碰到的设计模式有代理.工厂.单例.反射模式等等.下面就对工厂模式模拟spring的bean加载过程进行解析,如果对工厂模式不熟悉的,具体可以先去学习一下工厂 ...

  4. spring 配置bean

    Main(测试方法) public class Main { public static void main(String[] args) { //1.创建Spring 的IOC容器对象: //spr ...

  5. 在Spring的bean中注入HttpServletRequest解密

    我们可以在Spring的bean中轻松的注入HttpServletRequest,使用@Autowired HttpServletRequest request;就可以了. 但是,为什么我们可以直接这 ...

  6. spring:bean的定义

    一个完整的Bean的配置文件: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE beans ...

  7. paip.spring 获取bean getBean 没有beanid的情况下

    paip.spring 获取bean  getBean 没有beanid的情况下 spring能自动扫描带有注解的bean文件.. 作者Attilax  艾龙,  EMAIL:1466519819@q ...

  8. spring中bean配置和bean注入

    1 bean与spring容器的关系 Bean配置信息定义了Bean的实现及依赖关系,Spring容器根据各种形式的Bean配置信息在容器内部建立Bean定义注册表,然后根据注册表加载.实例化Bean ...

  9. Spring(二)Bean入门

    一.BeanFactory介绍 1.1.Bean: 在Spring技术中是基于组件的 最基本了是最常用的单元 其实实例保存在Spring的容器当中 Bean通常被定义在配置文件当中,Bean实例化由S ...

随机推荐

  1. js和php语法区别

    参考 : https://www.wangjingxian.cn/php/51.html

  2. 深入理解C指针第一章小结1

    1.1 指针和内存,C程序在编译后,会以三种形式使用内存. (1) 静态/全局内存:在程序开始时分配,程序结束才消失,所有函数都能访问全局变量,static静态变量的作用域局限在定义它们的函数内部 ( ...

  3. (转)Vmware vSphere 5.0系列教程 vSphere网络原理及vSwitch简介 及一个host两个网卡说明

    转:http://andygao.blog.51cto.com/323260/817518/ 在一个物理网络拓扑中,通常都是路由器-交换机-PC机的连接,不同的服务器和PC机,通过交换机的连接而相互连 ...

  4. HDU-4825 Xor Sum(字典树求异或最大值)

    题目链接:点此 我的github地址:点此 Problem Description Zeus 和 Prometheus 做了一个游戏,Prometheus 给 Zeus 一个集合,集合中包含了N个正整 ...

  5. ASP.NET Core学习——4

    静态文件 静态文件(static files),例如HTML.CSS.图片和JavaScript之类的资源会被ASP.NET Core应用直接提供给客户端. 静态文件通常位于web root(< ...

  6. ebay上传图片的要求

    eBay's Picture Requirements Introduction to Pictures in Listings Pictures make an item more appealin ...

  7. date和string转换用joda包

    import org.joda.time.DateTime;import org.joda.time.format.DateTimeFormat;import org.joda.time.format ...

  8. C# - 怎么截取字符串中指定字符及其后面的字符

    方法1:去掉空格以及后面的字符   //怎么截取让date的值为"2011/12/9",即去掉空格以及后面的字符   string date = "2011/12/9 2 ...

  9. Retrofit全攻略——进阶篇

    最近事比较多,距离上次写文章已经过去了一个月了.上一篇文章Retrofit全攻略——基础篇 介绍了Retrofit的基础用法,这篇文章介绍点进阶的用法. 打印网络日志 在开发阶段,为了方便调试,我们需 ...

  10. require.js实现单页web应用(SPA)

    本文转载自:https://blog.csdn.net/qq_33401924/article/details/53815922 移动端单页应用基本上是做移动端最流行的的方式了,但是对于很多前端来说, ...