Your ApplicationContext is unlikely to start due to a @ComponentScan of the default

问题:** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.

翻译:警告:你的应用上下文可能没有启动,因为你将注解添加到了默认的package上面了。下面的堆栈信息中也有一句话包括了这个意思。

解决:(结合下图)

方法一:@SpringBootApplication(scanBasePackages = {"com.example"}),注解后面加上要扫描的包(当文件在java下时)

方法二(推荐):把启动项放到com.example包下,不需要加扫描包路径

@SpringBootApplication
public class YyshopApplication {

	public static void main(String[] args) {
		SpringApplication.run(YyshopApplication.class, args);
	}

}

原文地址:https://www.cnblogs.com/wjup/p/10576093.html