劳动是唯一导向知识的道路。——萧伯纳

使用:

1
2
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,
value = {WillExludeBean.class, AnotherWillExludeBean.class})})

即可

这里还有其他的过滤类型

例如注解

1
2
3
@ComponentScan(excludeFilters = @Filter(
type = FilterType.ANNOTATION,
value = Service.class))

切面

1
2
3
@ComponentScan(includeFilters = @Filter(
type = FilterType.ASPECTJ,
pattern = "com.example..*Service+"))

正则

1
2
3
@ComponentScan(includeFilters = @Filter(
type = FilterType.REGEX,
pattern = "com\\.example\\..*Service"))