Annotation Interface ReflectiveScan
Reflective
. Typically used on
@Configuration
classes but can be added to any bean.
Scanning happens during AOT processing, typically at build-time.
In the example below, com.example.app
and its subpackages are
scanned:
@Configuration
@ReflectiveScan("com.example.app")
class MyConfiguration {
// ...
}
Either basePackageClasses()
or basePackages()
(or its alias
value()
) may be specified to define specific packages to scan. If specific
packages are not defined, scanning will occur recursively beginning with the
package of the class that declares this annotation.
A type does not need to be annotated at class level to be candidate, and
this performs a "deep scan" by loading every class in the target packages and
search for Reflective
on types, constructors, methods, and fields.
Enclosed classes are candidates as well. Classes that fail to load are
ignored.
- Since:
- 6.2
- Author:
- Stephane Nicoll
- See Also:
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionClass<?>[]
Type-safe alternative tobasePackages()
for specifying the packages to scan for reflection usage.String[]
Base packages to scan for reflective usage.String[]
Alias forbasePackages()
.
-
Element Details
-
value
Alias forbasePackages()
.Allows for more concise annotation declarations if no other attributes are needed — for example,
@ReflectiveScan("org.my.pkg")
instead of@ReflectiveScan(basePackages = "org.my.pkg")
.- Default:
- {}
-
basePackages
Base packages to scan for reflective usage.value()
is an alias for (and mutually exclusive with) this attribute.Use
basePackageClasses()
for a type-safe alternative to String-based package names.- Default:
- {}
-
basePackageClasses
Class<?>[] basePackageClassesType-safe alternative tobasePackages()
for specifying the packages to scan for reflection usage. 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.
- Default:
- {}
-