在Springboot工程中,启动类注解@SpringbootApplication本身包含了@EnableAutoConfiguration、@Configuration、@ComponentScan
@SpringbootApplication自带的扫描范围:当前所在的包以及子包
当@SpringbootApplication 和 @ComponentScan同时使用时,我们定义的@ComponentScan会覆盖本身@SpringbootApplication的扫描范围
因此我们需要在@ComponentScan中添加当前工程需要扫描的包范围
例子:
工程目录: