第一次使用h2数据库,使用持久化模式时连接控制台会报异常:
Database "C:/Users/admin/test" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-212] 90149/90149 (帮助)
大意就是数据库文件不存在,自己提前手动创建或允许自动创建。
经过查阅官方文档,得到解决方法:
数据库链接url追加指令:
;IFEXISTS=TRUE
类似下图这样即可:
datasource:
driver-class-name: org.h2.Driver
username: root
password: root
url: jdbc:h2:~/test;IFEXISTS=TRUE
参考:
https://h2database.com/html/features.html#database_only_if_exists