eg:

1、现在给定一个项目包的结构:

 com.yk.controller

 com.yk.service

2、在SpringMVC.XML有以下的配置:

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

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

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

</context:component-scan>

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

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

 

2)<context:component-scan base-package="com.yk"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan>

这样的意思 不包括@controller

相关文章:

  • 2021-09-28
  • 2022-01-16
  • 2021-12-10
  • 2022-12-23
  • 2021-11-06
  • 2021-08-30
  • 2022-12-23
猜你喜欢
  • 2021-06-07
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案