我试图创建一个spring引导应用程序,将一些数据插入gcp mysql。但每次我试图运行应用程序时,它都会显示异常-
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文件。这里没有定义实际的paparmeters-
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
请帮忙。提前谢谢
1条答案
按热度按时间sz81bmfz1#
在cli上运行以下命令: