【发布时间】:2021-06-18 14:58:50
【问题描述】:
我需要连接到 GCP Dialogflow 以检测意图。我正在使用 SpringBoot 和 Java 连接到 Dialogflow。此应用程序在 Pivotal Cloud Foundry (PCF) 中运行,我不知道如何在此处设置 GOOGLE_APPLICATION_CREDENTIALS 环境变量。
此处建议的所有解决方案都使用gcloud、Google SDK 或在 Google Compute Engine 中运行的应用。这些解决方案不适用于我的架构。
GoogleCredentials 始终为 null,即使按照以下建议进行设置 -
GoogleCredentials.fromStream(new FileStream("creds.json"));
或
GoogleCredentials creds = null;
try {
creds = GoogleCredentials.fromStream(new FileInputStream("creds.json"));
} catch (Exception e) {
e.printStackTrace();
}
错误 -
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...
【问题讨论】:
标签: spring-boot google-cloud-platform dialogflow-es cloud-foundry