我们正在开发一个 Play 2.4 应用程序(Java API)。
出于开发目的,我们希望使用具有相对于项目根目录的 DB 文件路径的持久 H2 数据库。
在How to use an persistent H2 database in the Play Framework 而不是内存中,有 Play 2.0 的解决方案:
db.default.url="jdbc:h2:file:data/db"
但是,使用 Play 2.4 这似乎不起作用,但我收到错误消息,底部有以下异常:
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:data/db". Use an absolute path, ~/name, ./name, or the
baseDir setting instead. [90011-187]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
...
我可以使用绝对路径和相对于主目录的路径获得连接,如下所示:
db.default.url="jdbc:h2:file:/Users/foo/data/db"
或者
db.default.url="jdbc:h2:~/data/db"
但是,有没有办法引用项目根文件夹?