How does the springboot startup class cull and scan a package
- 2021-12-09 08:51:58
- OfStack
Start class culling to scan a package
Eliminate the error packet caused by not citing database in api
@ComponentScan(excludeFilters =
{
@ComponentScan.Filter(type = FilterType.REGEX,pattern = "com.integration.aop.log.service.*")
})
With this annotation configuration, you can eliminate a package so that Spring does not automatically scan the contents under the package.
Applicable to rely on api or other packages, 1 some unnecessary or unsupported objects are scanned, causing error reporting or memory consumption problems. With this configuration, these unnecessary scans can be removed.
Using regular expressions to exclude package scanning
// com.jiaobuchong.business And com.jiaobuchong.user.servic None of the classes under will be scanned
@ComponentScan(basePackages = {"com.jiaobuchong.order.service"},
excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX,
pattern = "com.jiaobuchong.business\\..*"),
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "com.jiaobuchong.user.service\\..*")})