Scanning only one class in the provided package
@ComponentScan.Filter is used to include or exclude classes from the provided based package. This example will only scan in the provided class (given by Filter#value element), the class is sub-class of ArrayInjectionScanExample
class.
@ComponentScan(basePackageClasses = ArrayInjectionScanExample.class,
useDefaultFilters = false,
includeFilters =
{@ComponentScan.Filter(
type = FilterType.ASSIGNABLE_TYPE,
value = ArrayInjectionScanExample.TestBean.class)})
IncludeFilters with multiple classes.
@Configuration
@ComponentScan(basePackageClasses = BeanConditionScanExample.class,
useDefaultFilters = false,
includeFilters = {@ComponentScan.Filter(
type = FilterType.ASSIGNABLE_TYPE,
value = {BeanConditionScanExample.MyClientBean.class,
BeanConditionScanExample.ServiceBeanImpl1.class,
BeanConditionScanExample.ServiceBeanImpl2.class})})
public class BeanConditionScanExample {
Original Post