java.sql.SQLNonTransientConnectionException: 无法创建与数据库服务器的连接 - Google Cloud Platform
java.sql.SQLNonTransientConnectionException: Could not create connection to database server- Google Cloud Platform
我正在尝试创建一个 spring 启动应用程序,它会在每次我尝试 运行 应用程序时将一些数据插入 GCP Mysql.But,它显示异常 -
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 file.Actual 未在此处定义的参数-
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
请提前help.Thanks
运行 在 CLI 上执行以下命令:
gcloud auth application-default login
我正在尝试创建一个 spring 启动应用程序,它会在每次我尝试 运行 应用程序时将一些数据插入 GCP Mysql.But,它显示异常 -
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 file.Actual 未在此处定义的参数-
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
请提前help.Thanks
运行 在 CLI 上执行以下命令:
gcloud auth application-default login