gpt4 book ai didi

java - 使用 VS Code 在 Spring Boot 中设置 GCP 环境变量

转载 作者:行者123 更新时间:2023-12-01 16:15:13 26 4
gpt4 key购买 nike

我正在尝试设置 GOOGLE_APPLICATION_CREDENTIALS,但不断收到此错误

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 credential

我在我的应用程序属性中定义了:

spring.cloud.gcp.project-id=PROJECT_ID
spring.cloud.gcp.credentials.location=lasspath:/src/main/resources/key.json

在pom文件中添加依赖:

 <dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-dialogflow</artifactId>
<version>1.0.0</version>
</dependency>

也尝试从终端(Windows)执行此操作,但没有成功:

> set GOOGLE_APPLICATION_CREDENTIALS="C:\Users\user\Desktop\****\******\src\main\resources\key.json"

最佳答案

如果您安装了 Google Cloud SDK,您可以在控制台中运行以下命令来设置应用程序默认凭据:

gcloud auth application-default login

请参阅文档中的更多详细信息: https://cloud.google.com/sdk/gcloud/reference/auth/application-default

关于java - 使用 VS Code 在 Spring Boot 中设置 GCP 环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62415863/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com