spring - 尝试在本地使用 H2 文件进行存储时忽略 Spring 数据源配置
问题描述
我正在尝试使用一些 REST API 和存储创建简单的 Spring Boot 应用程序以在本地运行。我使用Spring 初始化程序初始化了应用程序,现在尝试配置数据库以在本地进行测试,因此我将这些设置添加到application.properties
spring.datasource.url=jdbc:h2:file:~/data/my_app_db
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=usr
spring.datasource.password=123
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=update
spring.h2.console.enabled=true
spring.h2.console.path=/h2/console
spring.h2.console.settings.trace=false
spring.h2.console.settings.web-allow-others=false
据我了解,这应该配置我的 h2 控制台路径和文件数据库路径,但在日志中我得到以下输出:
INFO 22917 --- [ restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:4bcaeb11-32f9-442d-9e8f-439608ffd960'
我无法理解我错过了什么。这不应该工作吗?如果不是,为什么?
解决方案
推荐阅读
- continuous-integration - 如何在 GitHub Actions 中的运行之间缓存已安装的工具?
- html - 在 oracle 上选择带引号的列名
- python - 使用 python 打开的 Chrome 默认配置文件不会获取网站
- javascript - React Native:在方法的渲染函数中使用变量
- linux - Bash:选择文件名中带有“ Tb ”的所有文件名
- java - 迭代矩阵和标记节点为已访问的岛数
- uwp - uno 平台:在 UserControl 中,如何使绘制动作无效
- r - 在 dplyr 中组合表格
- python-3.x - 冷启动推荐系统实现
- c - 程序在我打印出值时有效,但在我不打印时无效