【发布时间】:2018-11-29 04:00:18
【问题描述】:
在我的 Spring Boot 应用程序中,我正在尝试配置 H2 数据库文件夹的路径。我想通过以下路径放置它:
/home/public/h2
配置如下:
# 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
导致以下错误:
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]
我也试过spring.datasource.url=jdbc:h2:file:~/home/public/h2,但没用。
我做错了什么以及如何正确配置路径?
【问题讨论】:
-
波浪号
~扩展到您的主目录。假设您的主目录是/home/public:除非您的数据库文件位于位置/home/public/home/public/h2,否则您应该删除波浪号~或/home/public。
标签: spring-boot spring-data-jpa spring-data datasource h2