无法将“”下的属性绑定到 com.zaxxer.hikari.HikariDataSource Spring Boot

新手上路,请多包涵

尝试运行 Spring Boot 应用程序时出现以下错误。

 Description:

Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:

    Property: driverclassname
    Value: oracle.jdbc.OracleDriver
    Origin: "driverClassName" from property source "source"
    Reason: Unable to set value for property driver-class-name

Action:

Update your application's configuration

这是我遇到的 同样问题,但我没有使用 maven。

我正在使用 spring Boot 2.0.0 和以下启动器。

 dependencies {
    compile "org.springframework.boot:spring-boot-starter-web"
    compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1"
    testCompile "org.springframework.boot:spring-boot-starter-test"
}

这是我的 application.properties 文件

spring.datasource.url= *****
spring.datasource.username= ******
spring.datasource.password= ******

原文由 user9735824 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.7k
2 个回答

正如 Stephane Nicoll 所说,您的类路径中没有驱动程序。您需要在您的 gradle 构建中包含 jdbc 驱动程序,如下所示。但是,您不必坚持我包含的驱动程序版本。

 dependencies {
    compile "org.springframework.boot:spring-boot-starter-web"
    compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1"
    testCompile "org.springframework.boot:spring-boot-starter-test"
    runtime('com.oracle:ojdbc7:12.1.0.2.0')
}

原文由 want2learn 发布,翻译遵循 CC BY-SA 4.0 许可协议

我也有同样的问题(Spring boot 2),

我修复了添加驱动程序类。

查找 application.properties 文件。

 spring.datasource.driver-class-name=com.mysql.jdbc.Driver

完整的代码。

 spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=upate
spring.datasource.url=jdbc:mysql://localhost:3306/database_name
spring.datasource.username=admin
spring.datasource.password=admin1234

原文由 bamossza 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题