项目启动报错无法连接数据库

image
image
启动项目时报错 : Could not connect to the main data store: postgres (114.116.25.244/svms_rel)(无法连接到主数据存储:postgres (114.116.25.244/svms_rel))
image
在数据库管理工具是可以正常测试链接的

第一张图右下角,有个 “See log for details” 的链接。点一下看看日志里面说的什么?

主要报错信息是 : 2023-05-23 06:23:11,904 [75671962] INFO - #o.j.s.m.i.ProjectDependenciesModelImpl - Cannot build Gradle model for module svms.svms-portal.main
java.lang.IllegalStateException: Cannot build Gradle model for module svms.svms-portal.main

呃,这个错不对。你得找连不上数据库的错。实在不行,复制一下全部日志发上来

字符太多, 回复时报502, 不然加微信我给你发log文件, 查看完之后回论坛交流, 或者你跟我说大概怎么找

论坛就可以上传log文件

idea1.log (2.8 MB)
idea2.log (2.3 MB)

日志里面也就说连接超时:

2023-05-24 15:42:14,412 [3241280]   WARN - #c.h.s.b.e.h.DbmsConnectionExceptionHandler - Could not connect to the main data store: postgres (114.116.25.244/svms_rel)
com.haulmont.studio.backend.exceptions.CubaDbmsConnectionException: org.postgresql.util.PSQLException: Connection 尝试逾时。
	at com.haulmont.studio.intellij.ui.dbupdate.DataStoreToDbState.get(DataStoreToDbState.java:83)
	at com.haulmont.studio.intellij.runconfiguration.InteractiveDbChecker.checkDatabaseState(InteractiveDbChecker.java:116)
	at com.haulmont.studio.intellij.runconfiguration.InteractiveDbChecker.canStart(InteractiveDbChecker.java:95)
	at com.haulmont.studio.intellij.runconfiguration.stepbefore.CheckDataBaseTaskProvider.executeTask(CheckDataBaseTaskProvider.java:74)
	at com.intellij.execution.impl.ExecutionManagerImpl$compileAndRun$1.run(ExecutionManagerImpl.kt:399)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:297)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.postgresql.util.PSQLException: Connection 尝试逾时。
	at org.postgresql.Driver$ConnectThread.getResult(Driver.java:429)
	at org.postgresql.Driver.connect(Driver.java:271)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:190)
	at com.haulmont.studio.backend.ed.ddl.DbManager.openConnection(DbManager.java:312)
	at com.haulmont.studio.backend.ed.ddl.DbManager.dbExists(DbManager.java:235)
	at com.haulmont.studio.intellij.ui.dbupdate.DataStoreToDbState.get(DataStoreToDbState.java:57)

你尝试重启一下数据库服务吧?这个问题应该不是CUBA的问题了。

之前也发生过这种情况, 把项目放在Mac电脑和Windows电脑上启动, Mac电脑上就报这个错, Windows就可以正常启动项目, 但是今天无缘无故就都报错, 但数据库管理工具的连接始终是正常的.

这个 IP 114.116.25.244 是华为云?是不是云上的数据库配置没有允许连接?解决postgreSql远程连接数据库超时的问题-数据库远程运维

这应该是你用了某些代理软件导致idea被设置了,你可以打开idea的设置看一下
image

选择No Proxy就可以吗

应该不行,你把你的idea的设置页面截图发出看下

image

这是我重新选择过的, 之前是 No Proxy选项

Help——>Edit Custom VM Options,添加以下内容后重启idea
-Dhttp.proxyHost
-Dhttp.proxyPort
-Dhttps.proxyHost
-Dhttps.proxyPort
-DsocksProxyHost
-DsocksProxyPort
image

继续保持No Proxy

image
image

你这ip都ping不通呢

image
image
我在终端ping可以正常ping通啊