【发布时间】:2021-09-07 02:55:07
【问题描述】:
“Etwas Ungewöhnliches ist passiert, das den Treiber fehlschlagen ließ. Bitte teilen Sie diesen Fehler mit.”
这意味着:
发生了一些不寻常的事情,导致驱动程序失败。请报告此错误。
我可以通过登录、验证和列出我现有的数据库,从本地计算机上的控制台连接到数据库。
首先我想可能是因为缺少凭据 json 文件。但我仍然得到错误(在这篇文章的结尾)
application.properties 文件
spring.profiles.active=postgresql
spring.sql.init.data-locations=classpath*:sql/data.sql
# JPA
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create
# JWT
jwt.secret=mart11
# Server
server.port=${port:8080}
# Postgre
spring.main.banner-mode=off
spring.sql.init.enabled=true
logging.level.org.springframework.data=INFO
logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG
和 application-postgresql.properties 文件:
spring.cloud.gcp.sql.database-name=mart11
spring.cloud.gcp.sql.instance-connection-name=mart11-reservation:europe-west1:mart11
spring.cloud.gcp.credentials.location=cloud-key/mart11-reservation-bb76b28dff7c.json
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.postgresql.util.PSQLException: Etwas Ungewöhnliches ist passiert, das den Treiber fehlschlagen ließ. Bitte teilen Sie diesen Fehler mit.
Caused by: org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.postgresql.util.PSQLException: Etwas Ungewöhnliches ist passiert, das den Treiber fehlschlagen ließ. Bitte teilen Sie diesen Fehler mit.
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.postgresql.util.PSQLException: Etwas Ungewöhnliches ist passiert, das den Treiber fehlschlagen ließ. Bitte teilen Sie diesen Fehler mit.
Caused by: org.postgresql.util.PSQLException: Etwas Ungewöhnliches ist passiert, das den Treiber fehlschlagen ließ. Bitte teilen Sie diesen Fehler mit.
Caused by: java.lang.RuntimeException: Unable to obtain credentials to communicate with the Cloud SQL API
Caused by: java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
【问题讨论】:
-
@llic 发表了答案,有用吗?
标签: java spring postgresql google-cloud-platform cloud