使用@ConponentScan注解 现在一般项目都用Springboot开发,直接用@SpringBootApplication即可,该注解提供了baseScan的路劲配置能力,但是在exclude掉不想要的模块时就显得力不从心。我们打开@SprinbootApplication注解时发现其为三个注解的整合,其参数basescan**本质就是@ConponentScan注解,但是@SpringBootApplication无法定制化exclude能力,所以我们将@SpringBootApplication里的三个注解提炼出来,替代@SpringbootApplication 然后改造如下: @SpringBootConfiguration @EnableAutoConfiguration@ComponentScan(includeFilters = @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class)) public static void main(string[] args){ Springbootapplication.run(a.class); } 注意这块作者是直接用手机写的,全凭记忆,把大概过程记录一下。