<context:annotation-config/>,<context:component-scan/>,<mvc:annotation-driven/>区分
链接:http://blog.csdn.net/baple/article/details/16864175
链接:http://blog.csdn.net/Baple/article/details/16864835
传统的bean声明:<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
<context:annotation-config/>
向Spring容器注册AutowiredAnnotationBeanPostProcessor,CommonAnnotationBeanPostProcessor,
PersistenceAnnotationBeanPostProcessor,RequiredAnnotationBeanPostProcessor这4个BeanPostProcessor。
注册这4个BeanPostProcessor的作用,就是为了你的系统能够识别相应的注解。
-对于其他没有在spring容器中注册的bean,它不能起到注册bean的作用。
<context:component-scanbase-package=”xx.xx”/>
可以指定package扫描,
可以自动将带有@Autowired,@component,@service,@Repository等注解的对象注册到spring容器中的功能
隐式地在内部注册了AutowiredAnnotationBeanPostProcessor和CommonAnnotationBeanPostProcessor
-因此当使用<context:component-
scan/>后,除非需要使用PersistenceAnnotationBeanPostProcessor和
RequiredAnnotationBeanPostProcessor两个Processor的功能(例如JPA等)否则就可以
将<context:annotation-config/>移除了。
<context:component-scanbase-package="com.baobaotao">
<context:include-filtertype="regex" expression="com\.baobaotao\.service\..*"/>
<context:exclude-filtertype="aspectj" expression="com.baobaotao.util..*"/>
</context:component-scan>
<mvc:annotation-driven/>标签可简化springmvc的相关配置,默认情况下其会创建并注册实例:
DefaultAnnotationHandlerMapping:处理器映射器@Controller(默认注册)
AnnotationMethodHandlerAdapter-:处理器适配器
StringHttpMessageConverter
ByteArrayHttpMessageConverter
XmlAwareFormHttpMessageConverter
SourceHttpMessageConverter。
FormattingConversionServiceFactoryBean-:ConversionService类型转换
NumberFormatAnnotationFormatterFactory:@NumberFormat格式化
JodaDateTimeFormatAnnotationFormatterFactory::@DateTimeFormat格式化
LocalValidatorFactoryBean:@Valid数据校验
<context:annotation-config/>,<context:component-scan/>,<mvc:annotation-driven/>区分的更多相关文章
- Spring 开启Annotation <context:annotation-config> 和 <context:component-scan>诠释及区别
<context:annotation-config> 和 <context:component-scan>的区别 <context:annotation-config& ...
- Spring 配置 Annotation <context:annotation-config> 和 <context:component-scan>标签的诠释及区别
Spring 开启Annotation <context:annotation-config> 和 <context:component-scan>诠释及区别 <cont ...
- (转)Spring开启Annotation<context:annotation-config> 和 <context:component-scan>诠释及区别
转自:https://www.cnblogs.com/leiOOlei/p/3713989.html <context:annotation-config> 和 <context:c ...
- Spring----注释----开启Annotation <context:annotation-config> 和 <context:component-scan>诠释及区别
来源:http://www.cnblogs.com/leiOOlei/p/3713989.html <context:annotation-config> 和 <context:co ...
- spring3 jsp页面使用<form:form modelAttribute="xxxx" action="xxxx">报错,附连接数据库的spring MVC annotation 案例
在写一个使用spring3 的form标签的例子时,一直报错,错误信息为:java.lang.IllegalStateException: Neither BindingResult nor plai ...
- Spring < context:annotation-config> 、< context:component-scan>、< mvc:annotation-driven />注解配置
Spring 中在使用注解(Annotation)会涉及到< context:annotation-config> 和 < context:component-scan>配置, ...
- Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
严重: StandardWrapper.Throwableorg.springframework.beans.factory.BeanCreationException: Error creating ...
- SpringMVC配置文件详解:<context:annotation-config/>和<context:component-scan base-package=""/>和<mvc:annotation-driven />
原文地址:https://www.cnblogs.com/lcngu/p/5080702.html Spring配置文件详解:<context:annotation-config/>和&l ...
- context、config
Tomcat启动时已经创建了context,并使用它读取了web.xml中的参数,后台可以从context里获取参数 后台获取参数代码: ServletContext context = getSer ...
- [转载]Difference between <context:annotation-config> vs <context:component-scan>
在国外看到详细的说明一篇,非常浅显透彻.转给国内的筒子们:-) 原文标题: Spring中的<context:annotation-config>与<context:componen ...
随机推荐
- JDBC 的 PreparedStatement 与 Statement
import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import ...
- 安装webpack命令环境
1.通过cnpm安装webpack命令环境,如图 2.安装完后查看webpack的版本,如图
- [Vue]Vue实例的选项props传递数据props为驼峰式命名
在vue的中文官网有这样的说明: HTML 中的特性名是大小写不敏感的,所以浏览器会把所有大写字符解释为小写字符.这意味着当你使用 DOM 中的模板时,camelCase (驼峰命名法) 的 prop ...
- mvc 获取 HtmlHelper 表达式值
public static MvcHtmlString Try<TModel, TProperty>( this HtmlHelper<TModel> htmlHelper, ...
- 设计模式--桥梁模式C++实现
1定义 将抽象和实现解耦,使得两者可以独立变化 2类图 3实现 #pragma once #include<iostream> using namespace std; class Imp ...
- ubuntu下自动备份mysql数据库
转载自:Mayi mysql的安装目录为:/var/lib/mysql 下面咱们来一起完成自动备份mysql. 备份目录为:/home/mydb 并且在每天下午18:30分以mysqldata_201 ...
- Android_布局属性大全
RelativeLayout 第一类:属性值为true可false android:layout_centerHrizontal 水平居中 android:layout_centerVe ...
- matlab cvx工具包安装
cvx是凸函数优化的工具包 官网下载地址,http://cvxr.com/cvx/download/ 1 解压到任意文件,最好不要是matlab中的toolbox, 2 假如你解压倒了c盘sample ...
- hdu1151
题解: 二分图边覆盖 n-最大匹配 代码: #include<cstdio> #include<cmath> #include<algorithm> #includ ...
- LeetCode OJ:Remove Duplicates from Sorted List II(链表去重II)
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numb ...