简体   繁体   English

创建名为“dataSource”的 bean 时出错 [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]

[英]Error creating bean with name 'dataSource' [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]

i'm getting the following error when i try to debug a Spring boot with Gradle project in Eclipse当我尝试在 Eclipse 中使用 Gradle 项目调试 Spring Boot 时出现以下错误

Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': 
Unsatisfied dependency expressed through constructor 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 java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver

i've searched a lot, and most of the solutions came from something that is wrong in the application.properties file, but i can not figure what is wrong in mine我搜索了很多,大多数解决方案都来自 application.properties 文件中的错误,但我无法弄清楚我的问题出在哪里

server.port=8080
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/dices?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root

Any suggestion?有什么建议吗?

thanks谢谢

您可以尝试将compile("mysql:mysql-connector-java") 添加到 build.gradle 并再次检查吗?

The problem was with eclipse which was not downloading the dependencies.问题出在 eclipse 上,它没有下载依赖项。 Gradle configuration files were ok Gradle 配置文件没问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Boot-创建名称为'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration'的bean时出错 - Spring Boot - Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration' 在Docker容器上运行时创建名为'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration'的bean时出错 - Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration' when run on Docker container 创建名为'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration'的bean时出错: - Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': 创建名为“org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration”的bean时出错 - Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration' 创建名为 'org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration 的 bean 时出错 - Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration 创建名称为'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration'的bean时出错 - Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration' 在springboot中创建名为'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration的bean时出错 - Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration in springboot 创建名称为'transactionManager'的bean时出错:嵌套异常为java.lang.NoClassDefFoundError:org / springframework / jdbc / datasource / - Error creating bean with name 'transactionManager' :nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/ 错误org.springframework.beans.factory.BeanCreationException:创建类路径资源中定义的名称为“ dataSource”的bean时出错 - Error org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource CannotLoadBeanClassException:找不到名称为'dataSource'的bean的类[org.springframework.jdbc.datasource.DriverManagerDataSource] - CannotLoadBeanClassException: Cannot find class [org.springframework.jdbc.datasource.DriverManagerDataSource] for bean with name 'dataSource'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM