时间:2022-03-23 10:01:24 | 栏目:JAVA代码 | 点击:次
排除api中不引数据库导致的报错包
@ComponentScan(excludeFilters =
{
@ComponentScan.Filter(type = FilterType.REGEX,pattern = "com.integration.aop.log.service.*")
})
通过该注解配置,可以实现剔除某个包,让Spring不自动扫描该包下的内容。
适用于依赖api或者其他包时,一些不必要或不支持的对象被扫描到,引发的报错或内存占用等问题。通过该配置可以去掉这些不必要的扫描。
// com.jiaobuchong.business 和 com.jiaobuchong.user.servic 下的类都不会被扫描
@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\\..*")})