验证码: 看不清楚,换一张 查询 注册会员,免验证
  • {{ basic.site_slogan }}
  • 打开微信扫一扫,
    您还可以在这里找到我们哟

    关注我们

springboot启动报错bean找不到怎么解决

阅读:636 来源:乙速云 作者:代码code

springboot启动报错bean找不到怎么解决

      springboot启动报错bean找不到的原因解决

      一.普通的dao,service对应的实例bean不存在

      报错示例:

      1.Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.

      Reason: Failed to determine a suitable driver class。

      解决方案:

      1.确实不存在,加进去就好了

      2.类存在,但是spring没有扫描到,注意启动类所在位置,springboot默认扫描的是启动类所在目录下的子包和类,如下图1.2所示。另外可以使用@componentScan这个注解指定扫描的包:示例@componentScan({“xxx.xx”,“xxx.xx”})

      springboot启动报错bean找不到怎么解决

      二.由于bean的加载顺序和配置文件的关系

      1.请参考以下博文

      https://www.yisu.com/article/222850.htm

      https://www.yisu.com/article/190698.htm

      https://www.yisu.com/article/229466.htm

      补充:Springboot启动报错之类文件具有错误的版本 61.0, 应为 52.0

      启动Springboot项目时候报错

      java: 无法访问org.springframework.boot.SpringApplication
      错误的类文件: /D:/Maven/apache-maven-3.6.3/repository/org/springframework/boot/spring-boot/3.0.0/spring-boot-3.0.0.jar!/org/springframework/boot/SpringApplication.class
      类文件具有错误的版本 61.0, 应为 52.0
      请删除该文件或确保该文件位于正确的类路径子目录中。

      springboot启动报错bean找不到怎么解决

      原因

      SpringBoot使用了3.0或者3.0以上,因为Spring官方发布从Spring6以及SprinBoot3.0开始最低支持JDK17,所以仅需将SpringBoot版本降低为3.0以下即可。

      springboot启动报错bean找不到怎么解决

      将SpringBoot版本降低为3.0以下 版本随意,刷新Maven重启即可

      springboot启动报错bean找不到怎么解决

    分享到:
    *特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: hlamps#outlook.com (#换成@)。
    相关文章
    {{ v.title }}
    {{ v.description||(cleanHtml(v.content)).substr(0,100)+'···' }}
    你可能感兴趣
    推荐阅读 更多>