【问题标题】:URL to H2 database in OpenshiftOpenshift 中 H2 数据库的 URL
【发布时间】:2018-06-18 12:17:23
【问题描述】:

我有一个 H2 数据库在自己的 openshift 中运行。我正在尝试弄清楚如何使用我的 spring-boot 应用并将其连接到我的 H2 容器。

在我的 spring-boot 应用程序中,我的 application.properties 文件夹中有以下配置:

# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2
# Datasource
#spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.url=jdbc:h2:mem:testdb;
spring.datasource.platform=h2
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=none
spring.datasource.continue-on-error=true
spring.datasource.initialization-mode=always
spring.datasource.driver-class-name=org.h2.Driver

spring.profiles.active=h2

我为 H2 和 spring 应用程序设置了路线和服务。 H2 的路由是http://database-h2-route-openshift.com,并且在端口 1521 上。将 URL 放入 application.properties 是行不通的

【问题讨论】:

  • 我正在寻找一个类似的解决方案,你有这个工作吗?你能分享一下你的想法吗?

标签: openshift h2


【解决方案1】:
  1. 这 2 个 pod 是否在同一个项目中? (假设两个 pod 在同一个项目中,我将继续这个答案)
  2. 确保此服务的 pod 列表中列出了 H2 pod。
  3. 这里不需要路由(如果两个 pod 在同一个项目中)。您只需要在spring.datasource.url 中指定service name

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多