`

<context:component-scan/> 标签解析

 
阅读更多

在spring 中<context:component-scan/>作用就是帮我们自动装配Bean,变处理好依赖关系。

首先  <context:component-scan/>是属于CustomElement,后来spring扩展补充的由ContextNamespaceHandler来解析命名空间然后由ClassPathBeanDefinitionScanner来扫描类路径来加载Bean。

然后会加载相应的BeanPostProcessor用于再生成bean时进行处理

1:ConfigurationClassPostProcessor 用来处理带有@Configuration注解的类

2:AutowiredAnnotationBeanPostProcessor

 用来处理@Autowired ,@Value,@Inject注解的依赖注入功能

3:RequiredAnnotationBeanPostProcessor

用来处理带有@Required注解的雨来注入

4:CommonAnnotationBeanPostProcessor

处理javax.annotation 包下注解@PostConstruct和@PreDestroy等

5:PersistenceAnnotationBeanPostProcessor

提供对jpa 相关注解的支持如@PersistenceUnit@PersistenceContext等

 

分享到:
评论

相关推荐

    springboot 基础简易实例, maven项目

    context-path:"/" --------------------------- DemoApplication 运行 main 方法即可启动 springboot --------------------------- package com.example.demo; import org.springframework.boot....

    Spring 报错:元素 "context:component-scan" 的前缀 "context" 未绑定的问题解决

    主要介绍了Spring 报错:元素 "context:component-scan" 的前缀 "context" 未绑定的问题解决的相关资料,需要的朋友可以参考下

    Spring扫描器—spring组件扫描使用详解

    NULL 博文链接:https://gaozzsoft.iteye.com/blog/1523898

    struts2<s:if>使用心得

    &lt;td&gt; &lt;s:set name="actorRef" value="actorId" /&gt; &lt;s:set name="taskName" value="name" /&gt; &lt;s:if test="#actorRef=='' or #actorRef==null"&gt;共享任务(&lt;a href="${pageContext.request.contextPath}/ga/...

    context:property-placeholder 和util:properties

    context:property-placeholder 和util:properties 博客:https://blog.csdn.net/u010476739/article/details/76735527

    spring-context-support-1.0.10-API文档-中文版.zip

    赠送jar包:spring-context-support-1.0.10.jar; 赠送原API文档:spring-context-support-1.0.10-javadoc.jar; 赠送源代码:spring-context-support-1.0.10-sources.jar; 赠送Maven依赖信息文件:spring-context-...

    打jar包注意点.docx

    1、先在pom.xml文件中加入&lt;build&gt;&lt;/build&gt;标签 &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt; &lt;version&gt;2.3.1&lt;/version&gt; ...

    springmvcmybatis

    &lt;context:component-scan base-package="com.flong.*" /&gt; &lt;!-- 引入配置文件 --&gt; &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; ...

    Mybatis Generator配置详解.md

    &lt;context id="DB2Tables" targetRuntime="MyBatis3"&gt; &lt;commentGenerator&gt; &lt;property name="suppressDate" value="true"/&gt; &lt;!-- 是否去除自动生成的注释 true:是 : false:否 --&gt; &lt;property name=...

    基于MyEclipse搭建maven+springmvc整合图文教程(含源码0

    &lt;context:component-scan base-package="Controller" /&gt; &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="prefix" value="/WEB-INF/views/" /&gt; ...

    让用户分别使用apple和cloud虚拟目录访问Web服务目录.docx

    注意:xml文件是区分大小写的,不可以将&lt;Context&gt;写成&lt;context&gt;。 步骤三: 重新启动Tomcat服务器 将jsp页面放到C:\wang或D:\MyBook\zhang下保存 步骤四: 在浏览器输入: ...

    struts2 标签库 帮助文档

    7. &lt;s:autocompleter&gt;&lt;/s:autocompleter&gt;-----自动完成&lt;s:combobox&gt;标签的内容,这个是ajax B: 1. &lt;s:bean name=""&gt;&lt;/s:bean&gt;-----类似于struts1.x中的,JavaBean的值 C: 1. &lt;s:checkbox&gt;&lt;/s:checkbox&gt;---...

    springweb3.0MVC注解(附实例)

    &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;classpath:applicationContext.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;!-- Spring 容器启动监听器 --&gt; &lt;listener&gt; &lt;listener...

    SpringMVC+Hibernate实例

    &lt;context:component-scan base-package="com.bbs"/&gt; &lt;!--注解支持--&gt; &lt;mvc:annotation-driven/&gt; &lt;!--视图解析--&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view....

    struts hibernate spring 集成时使用依赖注解的方式的秘籍

    //applicationContext.xml文件中添加 &lt;beans xmlns="http://www.springframework.org/schema/beans" ... ... &lt;context:component-scan base-package="com.haijian" /&gt;

    quartz 定时任务

    &lt;context:component-scan base-package="cn.ly.quartz.service" /&gt; &lt;!-- job --&gt; &lt;bean id="helloJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean"&gt; &lt;property name="job...

    spring applicationContext 配置文件

    &lt;context:component-scan base-package="com.ccc"/&gt; &lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" p:order="0" /&gt; &lt;!-- 配置事务管理器 針對MES數據庫-...

    struts2.3+hibernate3.6+spring3.1整合的纯xml配置的小项目

    &lt;context:component-scan base-package="org.whvcse"&gt;&lt;/context:component-scan&gt; &lt;tx:annotation-driven transaction-manager="txManager" /&gt; &lt;!-- &lt;aop:config&gt; &lt;aop:pointcut id="defaultServiceOperation" ...

    springmvc-ibatis

    &lt;context:component-scan base-package="com.org"/&gt; &lt;bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="viewClass" value="org....

    Spring AOP配置源码

    @Component("userService")等价于在spring配置文件中定义一个&lt;bean id="userService"/&gt; @Resource(name="userDAO")将userDA注入进来 写一个拦截器的类 package com.spring.aop; import org.springframework....

Global site tag (gtag.js) - Google Analytics