【解决】Spring boot 启动失败:Your ApplicationContext is unlikely to start due to a @ComponentScan of the def

Spring boot启动失败:Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package

  • 问题
  • 排查
  • 解决

问题

Springboot 项目启动失败,报错如下:
Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package
(由于默认包的@ComponentScan,您的ApplicationContext不太可能启动)

【解决】Spring boot 启动失败:Your ApplicationContext is unlikely to start due to a @ComponentScan of the def_第1张图片

排查

我们查看入口函数,并没有ComponentScan标签,所以猜测为默认入口函数位置与默认扫描位置没有对应上导致。
【解决】Spring boot 启动失败:Your ApplicationContext is unlikely to start due to a @ComponentScan of the def_第2张图片
所以,我们查看pom文件以及入口函数的位置:

  1. pom文件:
    【解决】Spring boot 启动失败:Your ApplicationContext is unlikely to start due to a @ComponentScan of the def_第3张图片
  2. 入口函数位置
    【解决】Spring boot 启动失败:Your ApplicationContext is unlikely to start due to a @ComponentScan of the def_第4张图片
    很显然,我们的路径与pom文件的路径不一致,此时已经有了解决方案。

解决

很简单,重新创建package,与pom文件一致即可:
【解决】Spring boot 启动失败:Your ApplicationContext is unlikely to start due to a @ComponentScan of the def_第5张图片
修改后,成功运行!

你可能感兴趣的:(问题解决方案,intellij,idea,开发环境,spring,boot,后端,java)