最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
springboot启动类剔除扫描某个包代码示例
时间:2022-06-29 02:06:02 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下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..*")})
相关文章
- jm天堂网页版官方登录入口-jm天堂网页版直接登录入口 12-14
- 蝉妈妈网页版直达入口-蝉妈妈app官方正版入口在哪 12-14
- 豆包AI智能在线网页解析神器-豆包AI智能在线会议纪要生成助手 12-14
- 小红书Web官网登录入口-小红书官方网页版一键登录 12-14
- 苍云阅读app如何快速找到目录-目录入口位置 12-14
- 苹果ID登录官网入口 - 苹果Apple ID账户登录页面一键直达 12-14