/*
* @since 3.1
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@Repeatable(ComponentScans.class)
public @interface ComponentScan {
/**
* Alias for {@link #basePackages}.
* <p>Allows for more concise annotation declarations if no other attributes
* are needed — for example, {@code @ComponentScan("org.my.pkg")}
* instead of {@code @ComponentScan(basePackages = "org.my.pkg")}.
*/
@AliasFor("basePackages")
String[] value() default {
};
/**
* Base packages to scan for annotated components.
* <p>{@link #value} is an alias for (and mutually exclusive with) this
* attribute.
* <p>Use {@link #basePackageClasses} for a type-safe alternative to
* String-based package names.
*/
@AliasFor("value")
String[] basePackages() default {
};
/**
* Indicates whether automatic detection of classes annotated with {@code @Component}
* {@code @Repository}, {@code @Service}, or {@code @Controller} should be enabled.
*/
boolean useDefaultFilters
Spring 源码分析之@ComponentScan 深入解读
最新推荐文章于 2024-01-13 16:10:08 发布
本文深入解读了Spring框架中的@ComponentScan注解,解释了其用于组件扫描的配置,包括basePackageClasses、basePackages或value属性的指定,以及如何与@Configuration结合使用。同时,讨论了FilterType在@ComponentScan中的作用,如includeFilters和excludeFilters的过滤规则,以及FilterType的几种类型,如ANNOTATION、ASSIGNABLE_TYPE、ASPECTJ、REGEX和CUSTOM。
摘要由CSDN通过智能技术生成