zoukankan      html  css  js  c++  java
  • Spring学习笔记(三)-类扫描的注解

    类扫描的注解:

       1、在spring的配置文件中导入命名空间

             xmlns:context="http://www.springframework.org/schema/context"

             http://www.springframework.org/schema/context

             http://www.springframework.org/schema/context/spring-context-2.5.xsd

      2、<context:component-scan base-package="cn.itcast.annotation.scan"></context:component-scan>

           1、 该注解解析器包含了两个功能:依赖注入和类扫描

           2、在base-package包及子包下查找所有的类

      3、如果一个类上加了@Component注解,就会进行如下的法则

            如果其value属性的值为""

                  @Component

                  public class Person {}

                  ==

                  <bean id="person" class="..Person">

           如果其value属性的值不为""

                  @Component("p")

                  public class Person {}

                  ==

                  <bean id="p" class="..Person">

      4、按照@Resource的法则再次进行操作
  • 相关阅读:
    [BZOJ 2820]YY的GCD
    [POI 2007]ZAP-Queries
    [USACO 04OPEN]MooFest
    [HAOI 2011]Problem b
    [COGS 2258][HZOI 2015]复仇的序幕曲
    [UOJ 41]【清华集训2014】矩阵变换
    [POJ 3487]The Stable Marriage Problem
    [POJ 3252]Round Numbers
    [COGS 1799][国家集训队2012]tree(伍一鸣)
    [SDOI 2011]计算器
  • 原文地址:https://www.cnblogs.com/toge/p/6114672.html
Copyright © 2011-2022 走看看