gpt4 book ai didi

java - 创建名称为 'dataSource' 的 bean 时出错 [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]

转载 作者:行者123 更新时间:2023-12-01 18:24:17 24 4
gpt4 key购买 nike

当我尝试在 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

我搜索了很多,大多数解决方案都来自 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

有什么建议吗?

谢谢

最佳答案

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

关于java - 创建名称为 'dataSource' 的 bean 时出错 [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60253070/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com