@Retention(value=RUNTIME) @Target(value=TYPE) @Documented public @interface ComponentScan
Configurationclasses. Provides support parallel with Spring XML's
basePackages() or its alias
value() may be specified to define specific packages to scan. If specific
packages are not defined scanning will occur from the package of the
class with this annotation.
Note that the
<context:component-scan> element has an
annotation-config attribute, however this annotation does not. This is because
in almost all cases when using
@ComponentScan, default annotation config
processing (e.g. processing
@Autowired and friends) is assumed. Furthermore,
AnnotationConfigApplicationContext, annotation config processors are
always registered, meaning that any attempt to disable them at the
@ComponentScan level would be ignored.
Configuration Javadoc for usage examples.
|Modifier and Type||Optional Element and Description|
Type-safe alternative to
Base packages to scan for annotated components.
Specifies which types are not eligible for component scanning.
Specifies which types are eligible for component scanning.
Controls the class files eligible for component detection.
Indicates whether proxies should be generated for detected components, which may be necessary when using scopes in a proxy-style fashion.
Indicates whether automatic detection of classes annotated with
Alias for the
public abstract String value
basePackages()attribute. Allows for more concise annotation declarations e.g.:
public abstract String basePackages
value() is an alias for (and mutually exclusive with) this attribute.
basePackageClasses() for a type-safe alternative to String-based package names.
public abstract Class<?> basePackageClasses
basePackages()for specifying the packages to scan for annotated components. The package of each class specified will be scanned.
Consider creating a special no-op marker class or interface in each package that serves no purpose other than being referenced by this attribute.
public abstract Class<? extends BeanNameGenerator> nameGenerator
BeanNameGeneratorclass to be used for naming detected components within the Spring container.
The default value of the
BeanNameGenerator interface itself indicates
that the scanner used to process this
@ComponentScan annotation should
use its inherited bean name generator, e.g. the default
AnnotationBeanNameGenerator or any custom instance supplied to the
application context at bootstrap time.
public abstract Class<? extends ScopeMetadataResolver> scopeResolver
ScopeMetadataResolverto be used for resolving the scope of detected components.
public abstract ScopedProxyMode scopedProxy
The default is defer to the default behavior of the component scanner used to execute the actual scan.
Note that setting this attribute overrides any value set for
public abstract String resourcePattern
public abstract boolean useDefaultFilters
@Controllershould be enabled.
public abstract ComponentScan.Filter includeFilters
Further narrows the set of candidate components from everything in
basePackages() to everything in the base packages that matches
the given filter or filters.