zoukankan      html  css  js  c++  java
  • Spring与SpringMVC重复扫描问题

    在SpringMVC.XML有以下的配置:

    《!--扫描@controller注解--》

    <context:component-scan base-package="com.xxx.controller">
    
       <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
    
    </context:component-scan>

    把最终的包写上,而不能这样写base-package="com.xxx"。这种写法对于:include-filter来讲它都会扫描。而不是仅仅扫描@controller

    如果这样,一般会导致一个常见的错误---事务不起作用。解决的方法:添加:use-default-filters=”false”

    <context:component-scan base-package="com.xxx" use-default-filters="false"> 
    
      <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> 
    
    </context:component-scan>

     在Spring.xml配置

    <context:component-scan base-package="com.xxx"> 

      <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />

    </context:component-scan>

    这样的意思 不包括@controller

  • 相关阅读:
    小白的进阶之路7
    小白的进阶之路6
    小白的进阶之路5
    小白的进阶之路4
    小白的进阶之路3
    小白的进阶之路2
    小白的进阶之路1
    02CSS布局13
    02css定位12
    02css盒子模型11
  • 原文地址:https://www.cnblogs.com/fg-fd/p/9916682.html
Copyright © 2011-2022 走看看