Package org.springframework.context.annotation

# Annotation Interface ComponentScan.Filter

Enclosing class:
  ComponentScan

@Retention(RUNTIME) @Target({}) public static @interface ComponentScan.Filter
Declares the type filter to be used as an include filter or exclude filter.

## Optional Element Summary

Optional Elements
Modifier and Type
Optional Element
Description
`Class<?>[]`
`classes`
The class or classes to use as the filter.
`String[]`
`pattern`
The pattern (or patterns) to use for the filter, as an alternative to specifying a Class `value()`.
`FilterType`
`type`
The type of filter to use.
`Class<?>[]`
`value`
Alias for `classes()`.

## Element Details

### type

FilterType type
The type of filter to use.

Default is `FilterType.ANNOTATION`.

See Also:
  - `classes()`
  - `pattern()`

Default:
  ANNOTATION

### value

@AliasFor("classes") Class<?>[] value
Alias for `classes()`.

See Also:
  - `classes()`

Default:
  {}

### classes

@AliasFor("value") Class<?>[] classes
The class or classes to use as the filter.

The following table explains how the classes will be interpreted based on the configured value of the `type()` attribute.

`FilterType` | Class Interpreted As
--- | ---
`ANNOTATION` | the annotation itself
`ASSIGNABLE_TYPE` | the type that detected components should be assignable to
`CUSTOM` | an implementation of `TypeFilter`

When multiple classes are specified, OR logic is applied — for example, "include types annotated with `@Foo` OR `@Bar`".

Custom `TypeFilters` may optionally implement any of the following `Aware` interfaces, and their respective methods will be called prior to `match`:

- `EnvironmentAware`
- `BeanFactoryAware`
- `BeanClassLoaderAware`
- `ResourceLoaderAware`

Specifying zero classes is permitted but will have no effect on component scanning.

Since:
  4.2
See Also:
  - `value()`
  - `type()`

Default:
  {}

### pattern

String[] pattern
The pattern (or patterns) to use for the filter, as an alternative to specifying a Class `value()`.

If `type()` is set to `ASPECTJ`, this is an AspectJ type pattern expression. If `type()` is set to `REGEX`, this is a regex pattern for the fully-qualified class names to match.

See Also:
  - `type()`
  - `classes()`

Default:
  {}