zoukankan      html  css  js  c++  java
  • spring中的context:include-filter和context:exclude-filter的区别

    (1)在Spring-MVC.xml中有以下配置:

    <!-- 扫描@Controller注解 -->
    <context:component-scan base-package="com.fq.controller">
        <context:include-filter type="annotation"
            expression="org.springframework.stereotype.Controller" />
    </context:component-scan>

    可以看出要把最终的包写上,而不能这样写base-package=”com.fq”。这种写法对于include-filter来讲它都会扫描,而不是仅仅扫描@Controller。这点需要注意。他一般会导致一个常见的错误,那就是事务不起作用,补救的方法是添加use-default-filters=”false”。

    (2)在Spring-common.xml中有如下配置:

    <!-- 配置扫描注解,不扫描@Controller注解 -->
    <context:component-scan base-package="com.fq">
        <context:exclude-filter type="annotation"
            expression="org.springframework.stereotype.Controller" />
    </context:component-scan>

    可以看到,他是要扫描com.fq包下的所有子类,不包含@Controller。对于exculude-filter不存在包不精确后都进行扫描的问题。

  • 相关阅读:
    朱刘算法---有向图的最小生成树
    527D Clique Problem 判断一维线段没有两辆相交的最大线段数量
    Tex中的引号
    DAY 96 flask05
    DAY 95 flask04
    DAY 94 flask03
    DAY 93 flask02
    DAY 92 flask01
    DAY 91 爬虫05
    DAY 90 爬虫04
  • 原文地址:https://www.cnblogs.com/austinspark-jessylu/p/7705024.html
Copyright © 2011-2022 走看看