[英]Failed to bind properties under " to com.zaxxer.hikari.HikariDataSource:" Springboot
[英]Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource
我正在尝试运行无法访问 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>
当我运行应用程序时,无法绑定属性
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 的手动导入后,请确保具有 H2 的runtime
范围:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
runtime
作用域正在做什么的简短说明:
运行时对于单元测试和运行时所需的依赖项很有用,但在编译时则不然。 这通常可能是动态加载的代码,例如 JDBC 驱动程序,它们在程序代码中没有直接引用( Maven:“运行时”范围的目的是什么? )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.