spring mvc 注解掃描問題 ,掃描不到controller, use-default-filters="false"


今天搭了個spring mvc項目,怎么也掃描不到controller,最后發現問題在use-default-filters="false"上面,亂copy出的問題

(默認值是true,它的作用就是掃描一些相關的注解,包括了@controller,@Component,@Service,@Repository等,)

  <context:component-scan base-package="com.example" use-default-filters="false">

  </context:component-scan>


如果配置為false,會在下面尋找類似配置include-filter和exclude-filter,一個黑名單方式,一個白名單方式,上面兩個都沒配,所以默認不掃描
      <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
      <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM