ale*_*oid 0 datasource h2 spring-data spring-data-jpa spring-boot
在我的 Spring Boot 应用程序中,我尝试配置 H2 数据库文件夹的路径。我想通过以下路径放置它:
/home/public/h2
Run Code Online (Sandbox Code Playgroud)
配置如:
# Datasource
spring.datasource.url=jdbc:h2:file:/home/public/h2
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
Run Code Online (Sandbox Code Playgroud)
导致以下错误:
Caused by: org.h2.jdbc.JdbcSQLException: A file path that is implicitly relative to the current working directory is not allowed in the database URL "jdbc:h2:file:/home/public/h2". Use an absolute path, ~/name, ./name, or the baseDir setting instead. [90011-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357) ~[h2-1.4.197.jar:1.4.197]
Run Code Online (Sandbox Code Playgroud)
我也尝试过spring.datasource.url=jdbc:h2:file:~/home/public/h2 ,但没有成功。
我做错了什么以及如何正确配置路径?
请尝试使用jdbc:h2:./name(显式相对路径),或者
将系统属性设置h2.implicitRelativePath为true(以阻止此检查)。
对于 Windows,绝对路径还需要包含驱动器("C:/...")。
h2.implicitRelativePath=true
spring.datasource.url=jdbc:h2:~/home/public/h2
Run Code Online (Sandbox Code Playgroud)
或者
h2.implicitRelativePath=true
spring.datasource.url=jdbc:h2:file:~/home/public/h2
Run Code Online (Sandbox Code Playgroud)
欲了解更多详情,请查看此处...
| 归档时间: |
|
| 查看次数: |
14284 次 |
| 最近记录: |