【随手记录】关于 The following classes could not be excluded because they are not auto-configuration classes

用@SpringBootApplication(exclude = RibbonRule.class)排除类@bean注入的类的时候报错

The following classes could not be excluded because they are not auto-configuration classes.....

stackoverflow  和 spring 的issue 找到了答案,@SpringBootApplication的exclude  专门用来排除auto-configuration 也就是我们说的自动配置的类的,

如果我们想排除自己定义的@Bean,可以用 @ComponentScan(excludeFilters= {@ComponentScan.Filter(type=FilterType.ANNOTATION, value= {AvoidScan.class})})

猜你喜欢

转载自www.cnblogs.com/whaleX/p/10770303.html