相关文章推荐
满身肌肉的鸭蛋  ·  【Unity ...·  1 年前    · 
高大的蟠桃  ·  python-----TypeError: ...·  2 年前    · 
悲伤的拐杖  ·  Springboot2 ...·  2 年前    · 

Springboot报错Error creating bean with name ‘dataSource‘ defined in class path resource解决方案

2023年2月17日 下午5:56 技术随笔

spring boot 报错Error creating bean with name ‘dataSource’ defined in class path resource, Factory method ‘dataSource’ threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class解决方案

  • Lyric:割开两种精神的我
  • 在连接mysql的时候出现报错:

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
    	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
    	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
    	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
    	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
    	... 87 more
    Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
    

    1 从报错中可以看见找不到Datasource数据库的配置,经检查原来忘了在application.yml配置文件配置数据库信息了

    spring:
      datasource:
          #url: jdbc:mysql://[ip]:[port]/[name]?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
        url: jdbc:mysql://localhost:3306/mysqlTest?serverTimezone=UTC&characterEncoding=UTF-8
        username: root
        password: 123456
        driver-class-name: com.mysql.cj.jdbc.Driver
      sql:
        init:
          encoding: utf-8
    
  • 有时就是忘了一些配置信息导致报错
  • 作为程序员第 42 篇文章,每次写一句歌词记录一下,看看人生有几首歌的时间,wahahaha …

    Springboot报错Error creating bean with name ‘dataSource‘ defined in class path resource解决方案Springboot报错Error creating bean with name ‘dataSource‘ defined in class path resource解决方案Springboot报错Error creating bean with name ‘dataSource‘ defined in class path resource解决方案

    Lyric:割开两种精神的我

    版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

    文章由半码博客整理,本文链接:https://www.bmabk.com/index.php/post/110834.html

    (0)

    有时候,不是因为你没有能力,也不是因为你缺少勇气,只是因为你付出的努力还太少,所以,成功便不会走向你。而你所需要做的,就是坚定你的梦想,你的目标,你的未来,然后以不达目的誓不罢休的那股劲,去付出你的努力,成功就会慢慢向你靠近。

    导读:本篇文章讲解 CSS颜色操作案例Demo【彩色标记笔】,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com,来源:原文

    2023年5月26日 000

    追求适度,才能走向成功;人在顶峰,迈步就是下坡;身在低谷,抬足既是登高;弦,绷得太紧会断;人,思虑过度会疯;水至清无鱼,人至真无友,山至高无树;适度,不是中庸,而是一种明智的生活态度。

    导读:本篇文章讲解 一文贯通→过滤器与拦截器详解,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com,来源:原文

    2023年4月4日 000

    追求适度,才能走向成功;人在顶峰,迈步就是下坡;身在低谷,抬足既是登高;弦,绷得太紧会断;人,思虑过度会疯;水至清无鱼,人至真无友,山至高无树;适度,不是中庸,而是一种明智的生活态度。

    导读:本篇文章讲解 VM虚拟机安装Centos7,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com,来源:原文

    2023年4月10日 000

    导读:本篇文章讲解 ES6新特性⑤,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com,来源:原文

    也许你感觉自己的努力总是徒劳无功,但不必怀疑,你每天都离顶点更进一步。今天的你离顶点还遥遥无期。但你通过今天的努力,积蓄了明天勇攀高峰的力量。加油!

    2023年3月3日 000

    导读:本篇文章讲解 关于IllegalArgumentException occurred while calling setter for property,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

    2023年2月20日 000