base-package  

1、basePackages

扫描basePackage制定包(及其子包)下的类,以尝试创建bean。将带有@Repository,@Service@Controller@Component的都创建一个bean

注解@ComponentScanbasePackages属性的默认值是注解@ComponentScan所在类所处的包。


2use-default-filters属性

是来控制是否要使用默认的过滤器的。

默认的过滤器会去解析base-package下的含有@Component注解的类作为bean

其中@Repository, @Service, and @Controller都是@Component的子注解,故,默认的过滤器会将它们全部解析成bean

Spring的component-scan

3include-filterexclude-filter

自定义包含哪些注解和排除哪些注解。其中,exclude-filter优先级高于include-filter

Spring的component-scan

4component-scan会创建一个bean,不管这个beanid是默认的)是否已经在xml中通过bean标签创建了。只是不一定会保留到beanFactory里(因为如果已经有了就会抛弃调后创建的)。



还可参见

http://www.cnblogs.com/kevin-yuan/p/5068448.html


相关文章:

  • 2021-12-23
  • 2021-07-26
  • 2022-01-17
  • 2021-09-15
  • 2021-11-27
  • 2021-05-25
  • 2022-01-26
  • 2021-12-05
猜你喜欢
  • 2021-10-15
  • 2021-08-25
  • 2021-11-08
  • 2021-03-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案