首页 > 解决方案 > H2 控制台在配置和使用嵌入式本地持久性时不显示 Spring Boot 创建的表,即使它们存在

问题描述

jdbc:h2:[file:][<path>]<databaseName>我已经使用 Spring Data JPA 抽象将 H2 设置为带有 Spring Boot的嵌入式持久数据库('Embedded (Local) Database' with ),如下所示

spring.datasource.url=jdbc:h2:file:/home/data/embeddeddb;CACHE_SIZE=${spring.datasource.cache.size:131072}
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=someusr
spring.datasource.password=somepwd
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=none
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
#spring.h2.console.settings.trace=false
spring.h2.console.settings.web-allow-others=true

我将 放在schema.sql我的项目下resources,发现我能够通过CrudRepository. 如上所示,我还通过属性启用了 h2 控制台。

但是,当我使用我指定的相同 URL(如上)从 h2 控制台连接到数据库时,它不会显示我创建的表或配置的缓存大小。

这即使我可以使用@Query我的方法CrudRepository来查看它们是否存在。

我不确定我在这里缺少什么,有人可以解释一下吗?

谢谢

标签: javaspring-boothibernatespring-data-jpah2

解决方案


推荐阅读