问题描述
我在gitlab yml文件中处于后续阶段。
integration-tests:
image: mydocker-hub-id/mvn-intergration-tests-image:latest
stage: test
services:
- postgres
script:
- export PGPASSWORD=$POSTGRES_PASSWORD
- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
- cd source_code
- pg_isready
- mvn verify -P test-ci -DskipUTs=true
为命令pg_isready执行作业时,我的响应5432没有响应。 从每个集成测试执行测试时,我都会出错:
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.
此阶段使用的图像是基于postgres图像构建的,该图像还安装了maven和java 11。
spring应用程序无法与postgres服务器连接可能是什么问题。命令postgres --version
显示正确的版本。也可以命令
"psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
返回确定结果。
app.properties中的Spring db连接如下:
spring.datasource.url=jdbc:postgresql://localhost:5432/test
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)