今天搭了个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"/>

 

相关文章:

  • 2021-08-25
  • 2021-11-14
  • 2022-02-11
  • 2021-10-16
  • 2021-12-19
  • 2022-12-23
猜你喜欢
  • 2021-08-04
  • 2021-06-26
  • 2021-06-17
  • 2022-01-08
  • 2021-05-26
  • 2022-12-23
相关资源
相似解决方案