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

  • 相关阅读:
    Swift
    Swift
    第二章_session管理
    HDU-1387-Team Queue
    Install Orace 11g on Solaris 10 Sparc 64 bit
    Linux 多学习过程
    dispatch_once认识分析
    关于包围神经猫的想法实现
    嵌入在网站上Flash播放机(2)
    初学者应学会如何加快seo
  • 原文地址:https://www.cnblogs.com/fg-fd/p/9916682.html
Copyright © 2011-2022 走看看