【问题标题】:Failed to determine a suitable driver class无法确定合适的驱动程序类
【发布时间】:2019-03-18 08:03:07
【问题描述】:

启动应用程序时,看到以下错误:

上下文初始化期间遇到异常 - 取消刷新尝试:org.springframework.beans.factory.BeanCreationException:创建名为“blockDataController”的bean时出错:资源依赖注入失败; 嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“blockSummaryImpl”的 bean 时出错:注入资源依赖项失败;嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException: Error Creating bean with name 'prodCodeMapper' defined in file [D:\YueNiuProject\StockMarket\yueniu-stock-data\market-data-dao\target\classes\com\ yueniu\stock\market\data\mapper\block\ProdCodeMapper.class]:通过bean属性'sqlSessionFactory'表达的不满足的依赖关系; 嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:在类路径资源 [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class] 中定义名称为 'sqlSessionFactory' 创建 bean 时出错:通过方法 'sqlSessionFactory' 表达的依赖关系不满足参数0;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] 中定义名称为“dataSource”的 bean 创建时出错:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [com.zaxxer.hikari.HikariDataSource]:工厂方法 'dataSource' 抛出异常; 嵌套异常是 org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: 无法确定合适的驱动程序类

【问题讨论】:

  • 请分享您的 application.properties 和 pom 文件..
  • 在运行应用程序时,需要确保您使用的数据库的 JDBC 驱动程序包含在类路径中,并确保数据库连接 URL 正确。

标签: java spring spring-boot intellij-idea


【解决方案1】:

连接sql数据库,必须在application.properties中配置datasource

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://..
spring.datasource.username=//..
spring.datasource.password=//..

【讨论】:

    猜你喜欢
    • 2019-05-27
    • 2022-01-19
    • 2021-11-22
    • 2021-09-12
    • 2023-02-04
    • 2019-12-06
    • 2019-05-10
    • 2018-12-26
    • 2020-10-23
    相关资源
    最近更新 更多