注释类型 ServletComponentScan
@Target(TYPE) @Retention(RUNTIME) @Documented @Import(org.springframework.boot.web.servlet.ServletComponentScanRegistrar.class) public @interface ServletComponentScan
Enables scanning for Servlet components (filters,servlets, andlisteners). Scanning is only performed when using an embedded Servlet container.Typically, one of
value,basePackages, orbasePackageClassesshould be specified to control the packages to be scanned for components. In their absence, scanning will be performed from the package of the class with the annotation.- 从以下版本开始:
- 1.3.0
- 另请参阅:
WebServlet,WebFilter,WebListener
可选元素概要
可选元素 修饰符和类型 可选元素 说明 Class<?>[]basePackageClassesType-safe alternative tobasePackages()for specifying the packages to scan for annotated servlet components.String[]basePackagesBase packages to scan for annotated servlet components.String[]valueAlias for thebasePackages()attribute.
元素详细资料
value
@AliasFor("basePackages") String[] valueAlias for thebasePackages()attribute. Allows for more concise annotation declarations e.g.:@ServletComponentScan("org.my.pkg")instead of@ServletComponentScan(basePackages="org.my.pkg").- 返回:
- the base packages to scan
- 默认值:
- {}
basePackages
@AliasFor("value") String[] basePackagesBase packages to scan for annotated servlet components.value()is an alias for (and mutually exclusive with) this attribute.Use
basePackageClasses()for a type-safe alternative to String-based package names.- 返回:
- the base packages to scan
- 默认值:
- {}
basePackageClasses
Class<?>[] basePackageClasses
Type-safe alternative tobasePackages()for specifying the packages to scan for annotated servlet components. The package of each class specified will be scanned.- 返回:
- classes from the base packages to scan
- 默认值:
- {}