zoukankan      html  css  js  c++  java
  • [spring]<context:component-scan/>使用

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    //context命名空间 xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan base-package="com.sparta.trans" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan> </beans>


    base-package:

    告诉spring要扫描的包;


    use-default-filters=”false”:
    表示不要使用默认的过滤器。
    use-default-filters=”true”或不设置时表示会扫描包含Service,Component,Responsitory,Controller注释修饰类。


    <context:include-filter/>:
    <context:include-filter>为<context:annotation-config/>的子标签(另一个相对应的子标签为:<context:exclude-filter>);
    而<context:component-scan>包含了<context:annotation-config/>;

    filter标签的type和表达式说明如下:
    Filter TypeExamples ExpressionDescription
    annotation org.example.SomeAnnotation 符合SomeAnnoation的target class
    assignable org.example.SomeClass 指定class或interface的全名
    aspectj org.example..*Service+ AspetJ语法
    regex org.example.Default.* Regelar Expression
    custom org.example.MyTypeFilter Spring3新增自订Type,称作org.springframework.core.type.TypeFilter
  • 相关阅读:
    ad_imh
    pc send instructor pc ad
    数据、模型、IT系统认知
    量化投资认知
    LinAlgError: Last 2 dimensions of the array must be square
    转:Hadoop大数据开发基础系列:七、Hive基础
    Run-Time Check Failure #2
    0x00007FFC8C5325E7 (ucrtbased.dll)处(位于 DataStructure.exe 中)引发的异常: 0xC0000005: 读取位置 0xFFFFFFFFFFFFFFFF 时发生访问冲突。
    栈与后缀表达式C实现
    Jupyter使用
  • 原文地址:https://www.cnblogs.com/vickylinj/p/9522292.html
Copyright © 2011-2022 走看看