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
  • 相关阅读:
    <script>标签的加载解析执行
    百度地图API位置偏移的校准算法
    开源实时消息推送系统 MPush
    开源GIS软件 4
    Bootstrap 只读输入框
    javascript中的后退和刷新
    HTML中的文本框textarea标签
    Spring Boot 特性 —— SpringApplication
    SpringMVC使用POST方法传递数据,却出现Request method 'GET' not supported?
    springboot的登录拦截机制
  • 原文地址:https://www.cnblogs.com/vickylinj/p/9522292.html
Copyright © 2011-2022 走看看