【发布时间】:2021-02-06 09:49:59
【问题描述】:
我正在尝试创建一个将一些数据插入 GCP Mysql 的 Spring Boot 应用程序。但是每次我尝试运行应用程序时它都会显示异常 -
java.sql.SQLNonTransientConnectionException: Could not create connection to database server.
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
下面是我的 application.properties 文件。此处未定义实际参数-
spring.cloud.gcp.sql.database-name=DemoDatabase
spring.cloud.gcp.sql.instance-connection-name=xxxxxxxxxxx
spring.datasource.initialization-mode=always
spring.cloud.gcp.credentials.location=C:/Users/utkar/Downloads/spring-boot-7208e0222fb1.json
spring.datasource.url=jdbc:mysql://google/DemoDatabase?cloudSqlInstance=XXXXXXXXXXX&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false
spring.datasource.username=XXXXX
spring.datasource.password=XXXXXX
请帮忙。提前致谢
【问题讨论】:
标签: spring spring-boot google-cloud-platform spring-data-jpa spring-data