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 ...
随机推荐
- 使用User Primary Email作为GUID的问题
最近发现有人使用CRM的user primary email作为GUID, 并且做了plugin来控制user primary email. 这样做法是非常有问题而且会影响同名的再次注册的用户. 假如 ...
- MPU9250九轴陀螺仪--连接MPU9250
树莓派连接MPU9250九轴加速度传感器1,配线方法 树莓派侧 MPU9250侧 3.3V VCC (SDA)GPIO2 SDA (SCL)GPIO3 SCL GND GND 2,I2C有效在树莓派里 ...
- element-ui 点击获取table的行索引
<el-table :data="list" v-loading.body="listLoading" element-loading-text=&quo ...
- gcc ld 链接器相关知识,调试指令(程序员的自我修养----链接、装载与库)
最近解决一个动态链接上的问题,因为以前从来没有接触过这方面的知识,所以恶补了一下,首先要了解gcc编译指令(makefile),ld链接器的选项(还有连接脚本section指定内存位置),熟悉查看连接 ...
- 常用LINQ关键字用法汇总
背景 传统上,针对数据的查询都以简单的字符串表示,而没有编译时类型检查或 IntelliSense 支持.此外,还需要针对每种数据源学习一种不同的查询语言:SQL 数据库.XML 文档.各种 Web ...
- Django框架 连接Oracle -ServerName方式报错
连接前: 修改后:
- reshape的两个函数melt和dcast
reshape Reshape包主要是用来做数据变形的.其中主要的有两个函数melt和dcast1.其中melt主要用于宽变长,而dcast1主要用于长变宽.melt和dcast1是reshape2包 ...
- 日志监控文件中获取ip,每一分钟统计一次,超过200次的计入黑名单
一.日志文件access.log #.要从日志里面找到1分钟之内访问超过200次的 #.每分钟都运行一次 #.读取文件内容,获取到ip地址 #.把每个ip地址存起来{} #.判断ip访问的次数是否超过 ...
- Java文件File类学习总结
java.io.File类 代表文件和目录,在开发中,读取文件.生成文件.删除文件.修改文件的属性都会用到该类. 常见构造方法: public File(String pathName){} 以pat ...
- JeeCMS v7 SSRF导致任意文件写入
前言: 学习大佬的思路. from先知社区:https://xz.aliyun.com/t/4809 00X1: 是/ueditor/getRemoteImage.jspx 接口 通过构造upfile ...