0

我正在尝试使用具有云编辑器角色的服务帐户连接到 GCP 云 sql。我正在遵循此处给出的示例

使用服务帐户的 Spring Cloud GCP postgres 示例

我的 application.properties 文件

    # Set to the Postgres user you want to connect to; 'postgres' is the default user.
spring.datasource.username=username
spring.datasource.password=password
spring.cloud.gcp.sql.database-name=tablename
# This value is formatted in the form: [gcp-project-id]:[region]:[instance-name]
spring.cloud.gcp.sql.instance-connection-name=project-id:region:instancename
# So app starts despite "table already exists" errors.
spring.datasource.continue-on-error=true
# Enforces database initialization
spring.datasource.initialization-mode=always
spring.cloud.gcp.project-id=project-id
spring.cloud.gcp.credentials.location=file:src/main/resources/key.json

我正在低于凭据错误

 2020-05-11 17:10:21.494  INFO 99087 --- [nio-8085-exec-1] c.g.cloud.sql.core.CoreSocketFactory     : Connecting to Cloud SQL instance [[instance name] via SSL socket.
2020-05-11 17:10:21.494  INFO 99087 --- [nio-8085-exec-1] c.g.cloud.sql.core.CoreSocketFactory     : First Cloud SQL connection, generating RSA key pair.
2020-05-11 17:10:21.499 ERROR 99087 --- [nio-8085-exec-1] c.h.m.p.p.e.util.ExceptionManager        : Error occured

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.AbstractMethodError: org.springframework.cloud.gcp.autoconfigure.sql.SqlCredentialFactory.create()Lcom/google/api/client/http/HttpRequestInitializer;
4

1 回答 1

0

基于此链接,我认为而不是:

spring.cloud.gcp.credentials.location=file:src/main/resources/key.json

你应该使用:

spring.cloud.gcp.sql.credentials.location=file:src/main/resources/key.json
于 2020-05-12T12:55:16.897 回答