java - 无法确定合适的驱动程序类别

标签 java spring spring-boot intellij-idea

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

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blockDataController': Injection of resource dependencies failed;
    nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blockSummaryImpl': Injection of resource dependencies failed; nested exception is 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]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory';
    nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is 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

最佳答案

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

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

关于java - 无法确定合适的驱动程序类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52790545/

相关文章:

java - Spring中引用传递的问题

java - Spring boot-1.5.8 应用程序中的 Logback 从 1.1.11 升级到 1.3.0-alpha4

java - 为什么我的 JDBC 更新不起作用?

java - 在Android Studio中使用两个ViewModel从Fragments获取不同类型的数据

java - 如何迭代多个 map

java - 为什么自定义接收器会失败并显示 "NoClassDefFoundError: scala/runtime/AbstractPartialFunction"?

java - Hazelcast 无法与 Spring 安全一起使用(未找到 SessionRegistry bean)

java - 我想使用 Spring Controller 中的 Iterable 在 JSP 文件中创建和填充列表项

java - 部署后无法访问 Google App Engine 中的 Spring Boot 应用程序

spring-boot - 将 Mongeez 与 Spring Boot 和 Spring Data MongoDB 集成