`
erichua
  • 浏览: 509316 次
  • 性别: Icon_minigender_2
  • 来自: 远方
社区版块
存档分类
最新评论

spring读书笔记----<context:component-scan/>和<context:annotation-config/>

阅读更多

<context:annotation-config/>

该命名空间对注释驱动、属性文件引入、加载期织入等功能提供了便捷的配置。但注意它仅提供元数据信息。要使元数据信息真正起作用,必须让负责处理这些元数据的处理器工作起来。

<context:component-scan/>

使用annotation 自动注册bean,并检查@Required,@Autowired的属性已被注入。注意它不但启用了对类包进行扫描以实施注释驱动 Bean 定义的功能,同时还启用了注释驱动自动注入的功能(即还隐式地在内部注册了AutowiredAnnotationBeanPostProcessor 和 CommonAnnotationBeanPostProcessor)

 

总结为了简化注释,你可以直接用<context:component-scan/>替代<context:annotation-config/>

  • 大小: 87.8 KB
  • 大小: 90.1 KB
  • 大小: 130.5 KB
分享到:
评论

相关推荐

    拦截器与冲突解决

    NULL 博文链接:https://xj84.iteye.com/blog/2065681

    springboot 基础简易实例, maven项目

    &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;2.1.4.RELEASE&lt;/version&gt; &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt; &lt;/parent&gt; &lt;groupId&gt;com.example&lt;/groupId&gt; &lt;artifactId&gt;...

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

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

    springmvc-ibatis

    &lt;context:annotation-config/&gt; &lt;!-- 扫描包 --&gt; &lt;context:component-scan base-package="com.org"/&gt; &lt;bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver...

    springweb3.0MVC注解(附实例)

    &lt;context:component-scan base-package="com.baobaotao.web"/&gt; &lt;!-- ②:启动Spring MVC的注解功能,完成请求和注解POJO的映射 --&gt; &lt;bean class="org.springframework.web.servlet.mvc.annotation. ...

    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數據庫-...

    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....

    SpringMVC+Hibernate全注解整合

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

    基于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; ...

    spring3.2+strut2+hibernate4

    &lt;context:annotation-config /&gt; &lt;!-- &lt;bean id="sessionFactory"--&gt; &lt;!-- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;--&gt; &lt;!-- &lt;property name="configLocation"--&gt; &lt;!-- value=...

    (代码)SpringMVC第12讲:<mvc:annotation-driven/>

    SpringMVC第12讲:&lt;mvc:annotation-driven/&gt;

    维生药业小项目 SSH简单学习项目

    &lt;context:annotation-config/&gt; &lt;bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"&gt; &lt;property name="driverClass" value="com.mysql.jdbc.Driver"&gt;&lt;/property&gt; &lt;property name="jdbc...

    Spring注释 注入方式源码示例,Annotation

    &lt;context:component-scan base-package="Mode"&gt;&lt;/context:component-scan&gt; //表示在包mode下面的类将扫描带有@Component,@Controller,@Service,@Repository标识符的类并为之注入对象。 据说是因为XML配置太烦锁而...

    springjdbc

    &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /&gt; &lt;!-- apache.dbcp连接池的配置 --&gt; &lt;bean id="dataSource" class="org.apache.commons.dbcp....

    Spring3中配置DBCP,C3P0,Proxool,Bonecp数据源

    &lt;context:annotation-config /&gt; &lt;context:component-scan base-package="com.mvc" /&gt; &lt;mvc:annotation-driven /&gt; &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt; &lt;mvc:default-servlet-...

    dubbo.xsd阿里巴巴开源xsd文件

    &lt;xsd:annotation&gt; &lt;xsd:documentation&gt;&lt;![CDATA[ Namespace support for the dubbo services provided by dubbo framework. ]]&gt;&lt;/xsd:documentation&gt; &lt;/xsd:annotation&gt; &lt;xsd:complexType name=...

    Spring Context测试

    学习spring组件扫描(Component Scanning)的代码 ...&lt;context:annotation-config /&gt; &lt;context:component-scan base-package="com.test"&gt;&lt;/context:component-scan&gt; 2.在需要装配的类的上面全部加上@Component

    SSH整合&&SSH集成开发

    &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt; &lt;!-- 保证POJO中标注@Required的属性被注入 --&gt; &lt;bean class="org.springframework.beans.factory.annotation....

    XML address实验

    &lt;annotation&gt; &lt;documentation&gt; Addresses for International Purchase order schema Copyright 2000 Example.com. All rights reserved. &lt;/documentation&gt; &lt;/annotation&gt; &lt;complexType name="Address"&gt; ...

Global site tag (gtag.js) - Google Analytics