一、假设

        1、maven项目

        2、SpringBoot项目

        3、依赖了其他公共模块,需要将模块Service或Compont注册成Bean

        4、依赖中的模块,不想扫描某个包或某些包(可能冲突)

二、解决: 启动类上增加注解

@ComponentScan(basePackages = {"cn.hg"},
excludeFilters = {
        @ComponentScan.Filter(type = FilterType.REGEX, pattern = "ch.hg.oper.*")
        ,@ComponentScan.Filter(type = FilterType.REGEX, pattern = "ch.hg.pay.*")
})

示例图

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐