gpt4 book ai didi

java - 将 ''下的属性绑定(bind)到com.zaxxer.hikari.HikariDataSource失败

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

我正在尝试运行无法访问 H2 数据库的 Spring Boot 应用程序

   spring.datasource.initialization-mode=embedded
spring.datasource.url=jdbc:h2:mem:bitsapi;MODE=Oracle;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=

这些我的 pom.xml 我如何添加依赖项
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>

<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.9</version>
<scope>compile</scope>
</dependency>

当我运行应用程序时无法绑定(bind)属性
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-13 12:01:39,685 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter

***************************
APPLICATION FAILED TO START
***************************

Description:

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

Property: driverclassname
Value: org.h2.Driver
Origin: "driverClassName" from property source "source"
Reason: Failed to load driver class org.h2.Driver in either of HikariConfig class loader or Thread context classloader

Action:

Update your application's configuration

最佳答案

我猜你使用的是 Spring Boot Starter JPA。 Hikari Connection Pooling 依赖项已经出现此依赖项,我建议将其从您的pom.xml 中删除。并让 Spring Boot 管理版本。

删除 Hikari CP 的手动导入后,请确保拥有 runtime您的 H2 范围:

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
runtime 的简短说明范围正在做:

runtime is useful for dependencies required for unit tests and at runtime, but not at compile time. This may typically be dynamically loaded code, such as JDBC drivers, which are not directly referenced in the program code (Maven : what is the "runtime" scope purpose?)

关于java - 将 ''下的属性绑定(bind)到com.zaxxer.hikari.HikariDataSource失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60676066/

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