context:annotation-config配置和context:component-scan配置

<context:annotation-config> 是用于激活那些已经在spring容器里注册过的bean(无论是通过xml的方式还是通过package sanning的方式)上面的注解,是一个注解处理工具。

他的作用是式地向 Spring 容器注册

AutowiredAnnotationBeanPostProcessor、

CommonAnnotationBeanPostProcessor、

PersistenceAnnotationBeanPostProcessor、

RequiredAnnotationBeanPostProcessor

这4个BeanPostProcessor,注册这4个BeanPostProcessor的作用,就是为了你的系统能够识别相应的注解。也就是能够使用@Aautowired等注解。

<context:component-scan>除了具有<context:annotation-config>的功能之外,<context:component-scan>还可以在指定的package下扫描以及注册javabean 。

因此当使用 <context:component-scan/> 后,就可以将 <context:annotation-config/> 移除了。

时间: 2024-08-02 10:59:19

context:annotation-config配置和context:component-scan配置的相关文章

[org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on

<2015-4-10 下午02时55分35秒 CST> <Info> <Security> <BEA-090905> <Disabling the CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerifica

Context namespace element &#39;annotation-config&#39; and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser]

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class pa

Mingyang.net:org.springframework.context.annotation.ConflictingBeanDefinitionException

org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'configController' for bean class [net.mingyang.modules.system.ConfigController] conflicts with existing, non-compatible bean definition of same

context、config

Tomcat启动时已经创建了context,并使用它读取了web.xml中的参数,后台可以从context里获取参数 后台获取参数代码: ServletContext context = getServletContext(); String size = context.getInitParameter("size"); web.xml中参数配置: <context-param> <param-name>size</param-name> <

Context namespace element &#39;component-scan&#39; and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext.xml]; nested exception is java.lang.IllegalStateException: Context

spring注解注入:&lt;context:component-scan&gt;以及其中的context:include-filter&gt;和 &lt;context:exclude-filter&gt;的是干什么的?

转自:https://www.cnblogs.com/vanl/p/5733655.html spring从2.5版本开始支持注解注入,注解注入可以省去很多的xml配置工作.由于注解是写入java代码中的,所以注解注入会失去一定的灵活性,我们要根据需要来选择是否启用注解注入. 在XML中配置了这个标签后,spring可以自动扫描base-package下面或者子包下面的java文件,如果扫描有@Component @Service @Controller等这些注解的类,则把这些类注册为bean.

为什么applicationContext.xml和spring-servlet.xml中都有注解过滤&lt;context:component-scan base-package=&quot;myproject&quot;&gt; 和&lt;context:component-scan base-package=&quot;myproject.controller&quot; /&gt;

在刚学习SpringMVC框架整合时,你也许会产生疑问为什么Spring.xml和SpringMVC.xml中都有注解过滤. <context:component-scan base-package="myproject"> 和<context:component-scan base-package="myproject.controller" /> 在这里有一个比较有意思的问题,初学者也会产生困惑,那么他究竟有何不同?我思考和查询很久,话不

[转载]Context and Interception : The .NET Context

转载自:Context and Interception : The .NET Context Every new app domain starts with a single context, called the default context. The default context provides no component services at all. The main reason why it exists is to help maintain a consistent p

Android在Context详细解释 ---- 你不知道Context

                                                                                                                                    本文原创 ,转载必须注明出处 :http://blog.csdn.net/qinjuning 前言:本文是我读<Android内核剖析>第7章 后形成的读书笔记 ,在此向欲了解Android框架的书籍推荐此书. 大家好,  今天给大家

requirejs.config配置paths的时候,配置目录和配置文件的区别

假设我们的项目结构如下: index.html main.js libs --haha.js --cores --cores1.js --core2.js --utils --util1.js --util2.js --services --service1.js --service2.js 如果项目规模比较大,那么js文件将会非常多,通常我们会按照目录进行组织和分组.在上面的代码中如果我们想使用core1.js.core2.js.util1.js.util2.js.service1.js.se