|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=RUNTIME) @Target(value=TYPE) @Documented public @interface ComponentScan
Configures component scanning directives for use with @Configuration
classes.
Provides support parallel with Spring XML's <context:component-scan>
element.
One of basePackageClasses()
, basePackages()
or its alias
value()
must be specified.
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,
when using AnnotationConfigApplicationContext
, annotation config processors are
always registered, meaning that any attempt to disable them at the
@ComponentScan
level would be ignored.
See @Configuration
Javadoc for usage examples.
Configuration
Optional Element Summary | |
---|---|
java.lang.Class<?>[] |
basePackageClasses
Type-safe alternative to basePackages() for specifying the packages
to scan for annotated components. |
java.lang.String[] |
basePackages
Base packages to scan for annotated components. |
ComponentScan.Filter[] |
excludeFilters
Specifies which types are not eligible for component scanning. |
ComponentScan.Filter[] |
includeFilters
Specifies which types are eligible for component scanning. |
java.lang.Class<? extends BeanNameGenerator> |
nameGenerator
The BeanNameGenerator class to be used for naming detected components
within the Spring container. |
java.lang.String |
resourcePattern
Controls the class files eligible for component detection. |
ScopedProxyMode |
scopedProxy
Indicates whether proxies should be generated for detected components, which may be necessary when using scopes in a proxy-style fashion. |
java.lang.Class<? extends ScopeMetadataResolver> |
scopeResolver
The ScopeMetadataResolver to be used for resolving the scope of detected components. |
boolean |
useDefaultFilters
Indicates whether automatic detection of classes annotated with @Component
@Repository , @Service , or @Controller should be enabled. |
java.lang.String[] |
value
Alias for the basePackages() attribute. |
public abstract java.lang.String[] value
basePackages()
attribute.
Allows for more concise annotation declarations e.g.:
@ComponentScan("org.my.pkg")
instead of
@ComponentScan(basePackages="org.my.pkg")
.
public abstract java.lang.String[] basePackages
value()
is an alias for (and mutually exclusive with) this attribute.
Use basePackageClasses()
for a type-safe alternative to String-based package names.
public abstract java.lang.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 java.lang.Class<? extends BeanNameGenerator> nameGenerator
BeanNameGenerator
class to be used for naming detected components
within the Spring container.
public abstract java.lang.Class<? extends ScopeMetadataResolver> scopeResolver
ScopeMetadataResolver
to 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 scopeResolver()
.
ClassPathBeanDefinitionScanner.setScopedProxyMode(ScopedProxyMode)
public abstract java.lang.String resourcePattern
Consider use of includeFilters()
and excludeFilters()
for a more flexible approach.
public abstract boolean useDefaultFilters
@Component
@Repository
, @Service
, or @Controller
should 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.
resourcePattern()
public abstract ComponentScan.Filter[] excludeFilters
resourcePattern()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |