annotation-driven,annotation-config,component-scan的区别与作用
来源:互联网 发布:文化套利分析软件 编辑:程序博客网 时间:2024/05/22 15:04
<mvc:annotation-driven/>
相当于注册了DefaultAnnotationHandlerMapping和AnnotationMethodHandlerAdapter两个bean,配置一些messageconverter。即解决了@Controller注解的使用前提配置。并提供了:数据绑定支持,@NumberFormatannotation支持,@DateTimeFormat支持,@Valid支持,读写XML的支持(JAXB),读写JSON的支持(Jackson)。
一般在springmvc项目中的spring-mvc.xml中配置该信息,取代下面的方式:
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes" value="application/json" />
</bean>
</list>
</property>
</bean>
=============================
<context:annotation-config/>
隐式地向Spring容器中注册AutowiredAnnotationBeanPostProcessor、CommonAnnotationBeanPostProcessor、PersistenceAnnotationBeanPostProcessor 及 equiredAnnotationBeanPostProcessor 这 4 个 BeanPostProcessor。 在配置文件中使用<context:annotationconfig/>之前,必须在 <beans> 元素中声明 context 命名空间<context:component-scan/>。
是对包进行扫描,实现注释驱动Bean定义,同时将bean自动注入容器中使用。即解决了@Controller标识的类的bean的注入和使用。
=============================
<context:component-scan/>
配置项不但启用了对类包进行扫描以实施注释驱动 Bean 定义的功能,同时还启用了注释驱动自动注入的功能(即还隐式地在内部注册了 AutowiredAnnotationBeanPostProcessor 和 CommonAnnotationBeanPostProcessor),因此当使用 <context:component-scan/> 后,除非需要使用PersistenceAnnotationBeanPostProcessor和equiredAnnotationBeanPostProcessor两个Processor的功能(例如JPA等)否则就可以将 <context:annotation-config/> 移除了。
- annotation-driven,annotation-config,component-scan的区别与作用
- annotation-driven,annotation-config,component-scan的区别与作用
- annotation-driven,annotation-config,component-scan的区别与作用(转)
- annotation-config,annotation-scan,annotation-driven区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config, annotation-driven, compont-scan 区别
- annotation-config 和 component-scan 的区别
- <mvc:annotation-driven/>,<context:annotation-config/>,<context:component-scan/>详解
- <mvc:annotation-driven/> <context:annotation-config/> <context:component-scan>
- linux下的命令格式
- 广度优先搜索
- java实现简单算法(三)
- linux设备树dts移植详解
- 十一期机房合作验收总结-2015-8-10
- annotation-driven,annotation-config,component-scan的区别与作用
- poj 1062 昂贵的聘礼 (最短路)
- 用 AXMLPrinter2、baksmali、smali、dex2jar 反编译.xml文件
- oracle中Connect By用法介绍
- 开始博客之旅
- 费马小定理 素数判定 蒙哥马利算法
- MFC调用vlc动态库libvlc.dll实现简单播放器 中文路径处理
- rumtime记录
- C/C++_atoi,itoa功能及其实现原理