为什么 H2 数据库不在浏览器中显示我的 table

Why H2 database doesn't show my table in the browser

我知道 H2 是一个内存数据库,只要应用程序存在,它就存在 运行。我正在关注 this tutorial。它工作正常。但是当我尝试在浏览器中检查我的 table 而我的应用程序是 运行 时。但它在那里没有显示任何东西。怎么了?如何在浏览器中查看我的 table?

更新信息:-

application.properties:-

spring.datasource.url=jdbc:h2:file:C:/temp/test
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

# Enabling H2 Console
spring.h2.console.enabled=true

# Custom H2 Console URL
spring.h2.console.path=/h2

spring.jpa.hibernate.ddl-auto=none

#Turn Statistics on and log SQL stmts
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.generate_statistics=false
#logging.level.org.hibernate.type=trace
#logging.level.org.hibernate.stat=debug

logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} - %msg%n

主要class:-

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

您用来连接到 H2 数据库的连接字符串 (jdbc:h2:~/testdb) 似乎指向与您的连接字符串不同的数据库。您需要更改 H2 控制台的连接字符串以匹配它。单击断开连接按钮,它将带您进入连接表单。在 JDBC URL 字段中输入您的连接字符串

请更正属性文件中的连接 URL,如下所示:

spring.datasource.url=jdbc:h2:mem:testdb