Spring.xml中配置注解context:annotation-config和context:component-scan简述
XML中context:annotation-config和context:component-scan简述
<context:annotation-config/> 中文意思:<上下文:注解——配置/>
<context:component-scan base-package=" 扫描路劲" annotation-config=true/> 中文意思:<上下文:部件——扫描 基础——包=“扫描路径”
注解——配置=true/>(annotation-config=true是默认的配置可省略不写)
1.<context:annotation-config/>
<context:annotation-config/>配置的作用:是向Spring容器注册一次注入四个BeanPostProcessor
- AutowiredAnnotationBeanPostProcessor
- CommonAnnotationBeanPostProcessor
- PersistenceAnnotationBeanPostProcessor
- RequiredAnnotationBeanPostProcessor
AutowiredAnnotationBeanPostProcessor旧版注入方式<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>作用是能使用@Autowired注解
CommonAnnotationBeanPostProcessor旧版注入方式<bean class="org.springframework.beans.factory.annotation.CommonAnnotationBeanPostProcessor"/>作用是能使用@Resource、@PostConstruct、@PreDestroy注解;
PersistenceAnnotationBeanPostProcessor旧版注入方式<bean class="org.springframework.beans.factory.annotation.PersistenceAnnotationBeanPostProcessor"/>作用是能使用@PersistenceContext注解;
RequiredAnnotationBeanPostProcessor旧版注入方式<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>作用是能使用@Required注解;
<context:annotation-config/>的总结即在XML文件中配置<context:annotation-config/>不需要再配置上面四个ben对象;
2.<context:component-scan base-package=" 扫描路劲" annotation-config=true/>
作用:具有<context:component-config/>注解的功能,还能对指定的package下扫描以及注册javabean
Spring.xml中配置注解context:annotation-config和context:component-scan简述的更多相关文章
- Spring实战(十一) 在Spring XML中配置AOP
如果你没有源码,不能为通知类添加注解,又不想将AspectJ注解放入到你的代码中,必须选择XML配置了. 1.Spring XML配置文件 解析参考:http://www.cnblogs.com/bi ...
- Spring xml中进行面向切面的配置
Spring xml中进行面向切面的配置 XML: <?xml version="1.0" encoding="UTF-8"?> <beans ...
- 源码跟读,Spring是如何解析和加载xml中配置的beans
Spring版本基于: 跟踪代码源码基于: https://github.com/deng-cc/KeepLearning commit id:c009ce47bd19e1faf9e07f12086c ...
- [spring]Bean注入——在XML中配置
Bean注入的方式有两种: 一.在XML中配置 属性注入 构造函数注入 工厂方法注入 二.使用注解的方式注入@Autowired,@Resource,@Required 本文首先讲解在XML中配置的注 ...
- web.xml中配置Spring中applicationContext.xml的方式
2011-11-08 16:29 web.xml中配置Spring中applicationContext.xml的方式 使用web.xml方式加载Spring时,获取Spring applicatio ...
- 详解Java的Spring框架中的注解的用法
转载:http://www.jb51.net/article/75460.htm 1. 使用Spring注解来注入属性 1.1. 使用注解以前我们是怎样注入属性的 类的实现: class UserMa ...
- Spring|SpringMVC中的注解
文章目录 一.Spring注解 @Controller @ResuController @Service @Autowired @RequestMapping @RequestParam @Model ...
- 在web.xml中配置监听器来控制ioc容器生命周期
5.整合关键-在web.xml中配置监听器来控制ioc容器生命周期 原因: 1.配置的组件太多,需保障单实例 2.项目停止后,ioc容器也需要关掉,降低对内存资源的占用. 项目启动创建容器,项目停止销 ...
- Spring MVC中@RequestMapping注解使用技巧(转)
@RequestMapping是Spring Web应用程序中最常被用到的注解之一.这个注解会将HTTP请求映射到MVC和REST控制器的处理方法上. 在这篇文章中,你将会看到@RequestMapp ...
随机推荐
- axios delete
- 目标文件obj的各段 2
#程序的自我修养 page68
- 18.6 使用TFTP下载时ping不通或出现ping通下载失败
下载成功loading: #### 下载失败loading: T T T T 解决办法,使主机干净,即关闭360.主机防火墙,程序插除完后写入才可执行.[2018年6月28日15:16:33测试后,关 ...
- python 数字以及字符串(方法总结,有的可能理解错误)
数字类型(int): 在python 2中,数字类型可以分为整形,长整形,浮点型,以及复数.在python3中都是整形和长整形都称之为整形,且python3中没有限制. 1.int方法使用,用于转换字 ...
- MySQL 索引的增删查
查看索引: > SHOW INDEX FROM table_name; > SHOW KEYS FROM table_name; 删除索引: > DROP INDEX index ...
- kettle使用小结----脚本启动
初学kettle,使用kettle Spoon完成转换(ktr)或作业(kjb)的编写之后,执行作业可以在spoon中直接启动,因为我的需求是持续监控数据表的状态进行数据同步, 所以作业任务需要一直在 ...
- Python语法进阶
1.变量进阶 2.局部变量.全局变量 3.函数进阶 4.函数进阶
- Camp 前三日简单总结
1.#include <bits/stdc++.h> 后面别再忘了写 using namespace std; 2.在#include <bits/stdc++.h> 中 可以 ...
- BeanUtils使用
1.BeanUtils.populate 可以把一个map中的属性拷贝到实体javaBean,例子: Student: package com.cy.model; import org.apache. ...
- linux删除文件后,空间未释放的一种情况,使用lsof查看
linux某个目录空间快满了,删除了若干的文件后,使用df -h显示还是快满的,但是df -h *显示的总的文件大小又没那么大. 某个进程正在使用删除的文件,导致删除后,空间仍然不能释放. 查看rm掉 ...