最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
springboot启动类剔除扫描某个包代码示例
时间:2021-11-03 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下springboot启动类剔除扫描某个包代码示例,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
启动类剔除扫描某个包
排除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\..*")})
相关文章
- SpringBoot测试配置属性与web启动环境解析 10-24
- vue中将el-switch值true、false改为number类型的1和0解析 10-24
- Vue中的路由配置项meta使用解读 10-24
- SpringBoot自定义bean绑定解析 10-24
- SpringBoot常用计量与bean属性校验和进制数据转换规则解析 10-24
- 工厂方法在Spring框架中的运用介绍 10-24