@ComponentScan( excludeFilters = {@Filter( type = FilterType.CUSTOM, classes = {TypeExcludeFilter.class} ), @Filter( type = FilterType.CUSTOM, classes = {AutoConfigurationExcludeFilter.class} )} )是什么意思
时间: 2023-06-11 20:04:55
浏览: 154
这段[代码](https://geek.csdn.net/educolumn/1572ef9b473b4e00f6b2bf6d428b7c27?spm=1055.2569.3001.10083)是用来配置 Spring 的扫描注解,用于扫描包路径中的组件,从而将其注入到 Spring 容器中。其中,excludeFilters = {@Filter( type = FilterType.CUSTOM, classes = {TypeExcludeFilter.class} ), @Filter( type = FilterType.CUSTOM, classes = {[auto](https://geek.csdn.net/educolumn/0ed23d107a440608894f63cac98e73fb?spm=1055.2569.3001.10083)Configur[ati](https://geek.csdn.net/educolumn/150d7073277950db5f09620704e791cf?spm=1055.2569.3001.10083)onExcludeFilter.class} )} 指定了需要排除的组件类型和类名,TypeExcludeFilter.class 排除标记为 @Component 的类,而 [auto](https://geek.csdn.net/educolumn/0ed23d107a440608894f63cac98e73fb?spm=1055.2569.3001.10083)Configur[ati](https://geek.csdn.net/educolumn/150d7073277950db5f09620704e791cf?spm=1055.2569.3001.10083)onExcludeFilter.class 排除自动配置类。
相关问题
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class), @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
这是一个带有excludeFilters属性的@ComponentScan注解,其中excludeFilters指定了需要排除掉的Bean对象。具体来说,该注解中有两个Filter类型的规则需要排除:
1. type = FilterType.CUSTOM, classes = TypeExcludeFilter.class,表示排除所有Class对象,这些Class对象是Spring框架内部使用的,不需要扫描到。
2. type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class,表示排除所有自动配置类,这些自动配置类是Spring Boot自动配置功能的一部分,不需要手动进行配置。