【发布时间】:2021-01-06 03:47:29
【问题描述】:
我创建了一个 Spring Boot 应用程序,但我没有使用内存中的 H2 数据库,而是为 H2 数据库安装了 exe 并在外部使用它。现在我想将我的 Spring Boot 应用程序与这个外部 H2 数据库连接起来。我已经添加了依赖项,我已经在 application.properties 文件 中添加了所有必需的属性(您可以在下面看到)。我还创建了一个具有@Entity 注释的实体类。但是,当我尝试连接数据库时,即使使用不同的 URL 和用户名,它也会连接,并且我看不到那里的实体类表。那么我在哪里做错了,我错过了哪些事情,请告诉我。
供您参考,我的 Spring boot 应用程序在端口 - 8080 上运行,H2 数据库在 8082 上运行
spring.h2.driverClassName = org.h2.Driver
spring.h2.url = jdbc:h2:file:~/test2;DB_CLOSE_ON_EXIT=FALSE; AUTO_RECONNECT=TRUE
spring.h2.username = QW
spring.h2.password = root
spring.h2.console.enabled = true
spring.datasource.platform = h2
【问题讨论】:
标签: java spring-boot h2