Spring Boot连接ElephantSQL托管PostgreSQL数据库报错求助
Spring Boot 连接 ElephantSQL PostgreSQL 托管数据库报错
我正在开发一个基于Spring Boot的简易应用,选用PostgreSQL作为数据存储方案,数据库托管在ElephantSQL平台。目前Spring Boot应用无法正常连接数据库,报错信息为:
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
已确认信息
- 已通过pgAdmin4成功连接该ElephantSQL数据库,说明数据库访问权限、网络连接无问题。
- ElephantSQL提供的数据库连接信息:
- 数据库地址为ElephantSQL分配的远程地址(非localhost)
- 数据库名称、用户名、密码均已通过pgAdmin4验证正确
- Spring Boot
application.properties配置内容:spring.datasource.url=jdbc:postgresql://localhost:5432/xxx spring.datasource.username=xxx spring.datasource.password=xxx spring.datasource.driver-class-name=org.postgresql.Driver pom.xml已引入PostgreSQL驱动依赖:<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <scope>runtime</scope> </dependency>
恳请各位帮忙排查连接失败的原因,提供解决方案!
内容的提问来源于stack exchange,提问作者Eduardo Lopes
相关产品推荐
相关产品推荐

