【问题标题】:How to connect azure postgres from my microservice如何从我的微服务连接 azure postgres
【发布时间】:2021-04-06 09:36:12
【问题描述】:

我有一个微服务来从 json 读取数据并保存在本地 postgres 中,但现在我想使用 azure postgres 而不是本地 DB。当我尝试使用应用程序属性进行连接时,出现超时错误。我有什么遗漏吗?

在我的连接安全中,我启用了允许访问 Azure 服务,我还在防火墙规则中添加了我的 ip 地址,并且我的 SSl 设置被禁用。

我的本​​地 postgres 应用程序属性文件,运行良好

spring.datasource.url=jdbc:postgresql://localhost:5432/MyDB
spring.datasource.username=postgres
spring.datasource.password=1234
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.platform=postgres

我的 azure postgres 应用程序属性不工作

spring.datasource.url : myapp.postgres.database.azure.com/test
spring.datasource.username: adminmyapp@myapp
spring.datasource.password: 123456
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.platform=postgres

我的应用程序属性是否正确?

【问题讨论】:

    标签: java postgresql azure spring-boot


    【解决方案1】:

    我认为您还需要提及驱动程序,

    spring.datasource.url=jdbc:postgresql://myapp.postgres.database.azure.com:5432/MyDB
    

    【讨论】:

    • 我添加了..但我得到“连接尝试失败”
    • 我确定有问题,检查数据库名称 url 和一切
    • 谢谢,我会检查的!这是将我的微服务连接到 azure postgres 的正确方法吗?就像使用应用程序属性文件一样
    猜你喜欢
    • 2020-03-18
    • 1970-01-01
    • 2018-06-03
    • 2020-07-30
    • 2020-04-27
    • 2020-11-24
    • 1970-01-01
    • 2015-04-03
    • 1970-01-01
    相关资源
    最近更新 更多