Spring SpringBoot启动时 @ComponentScan 排除指定Bean初始化

Posted 抓手

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring SpringBoot启动时 @ComponentScan 排除指定Bean初始化相关的知识,希望对你有一定的参考价值。

在启动类上加入 @ComponentScan 注解,并设置excludeFilters即可排除指定Bean初始化:

@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = OrderService.class, ProductService.class))

以上是关于Spring SpringBoot启动时 @ComponentScan 排除指定Bean初始化的主要内容,如果未能解决你的问题,请参考以下文章