无法将 '' 下的属性绑定到 com.zaxxer.hikari.HikariDataSource Spring Boot
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50215936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource Spring Boot
提问by user9735824
I am getting following error when I try to run spring boot application.
当我尝试运行 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
This is same issueI have but i am not using maven.
这是我遇到的相同问题,但我没有使用 maven。
I am using spring Boot 2.0.0with following starters.
我正在使用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"
}
And this is my application.propertiesfile
这是我的application.properties文件
spring.datasource.url= *****
spring.datasource.username= ******
spring.datasource.password= ******
采纳答案by want2learn
As Stephane Nicollsaid, you don't have driver on your classpath. You need to include jdbc driver on your gradle build as below. However, you don't have to stick to driver version that I have included.
正如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')
}
回答by bamossza
Same problem with me (Spring boot 2),
我也有同样的问题(Spring Boot 2),
I Fixed add driver-class.
我修复了添加驱动程序类。
Look up application.propertiesfile.
查找application.properties文件。
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
Full code.
完整代码。
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
回答by Bibin Zacharias
I have added the below in properties file
我在属性文件中添加了以下内容
spring.datasource.driverclassname = com.mysql.jdbc.Driver hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.datasource.driverclassname = com.mysql.jdbc.Driver hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
and added the below in POM file
并在 POM 文件中添加以下内容
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
It is working fine now.
它现在工作正常。
回答by Stephane Nicoll
The driver is not on your classpath, this is an interesting problem and I think the failure analyzer can be improved to avoid that misleading message. If that's your problem, please confirm and open an issue so that we try to improve it.
驱动程序不在您的类路径上,这是一个有趣的问题,我认为可以改进故障分析器以避免出现误导性消息。如果这是您的问题,请确认并打开一个问题,以便我们尝试改进它。
回答by Dmitry Bogdanovich
I had the same error when updating from Spring Boot 2.0.6 to Spring Boot 2.1.6.
从 Spring Boot 2.0.6 更新到 Spring Boot 2.1.6 时,我遇到了同样的错误。
Explicitly setting driver class name spring.datasource.driver-class-name=com.mysql.jdbc.Driverin application.propertieshas resolved the issue
明确设置驱动类名spring.datasource.driver-class-name=com.mysql.jdbc.Driver中application.properties已经解决了这个问题
回答by Rebecca Douglas
In case anyone is running intelliJ this error isn't immediately clear it can be caused by a missing profile. Eg. missing vm args for -Dspring.profiles.active=local (or whatever your property file name might be)
如果有人正在运行 intelliJ,则此错误不会立即清除,可能是由于缺少配置文件造成的。例如。缺少 -Dspring.profiles.active=local 的 vm 参数(或任何您的属性文件名)
回答by Miraj Hamid
You have to add
你必须添加
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
dependency in your pom.xml file
pom.xml 文件中的依赖项

