Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法使用本地环境中的环境变量连接dialogflow_Java_Dialogflow Es - Fatal编程技术网

Java 无法使用本地环境中的环境变量连接dialogflow

Java 无法使用本地环境中的环境变量连接dialogflow,java,dialogflow-es,Java,Dialogflow Es,我创建了一个简单的对话框。 我想从本地环境(Linux)中的java应用程序中使用它。 我得到一个错误: 应用程序默认凭据不可用。如果在谷歌计算引擎中运行,它们是可用的。否则,必须定义指向定义凭据的文件的环境变量GOOGLE\u APPLICATION\u CREDENTIALS 我这样设置环境变量: export GOOGLE_APPLICATION_CREDENTIALS=“/home/me/*****.json” com.google.cloud 谷歌云对话流 0.99.0-alpha

我创建了一个简单的对话框。 我想从本地环境(Linux)中的java应用程序中使用它。 我得到一个错误:

应用程序默认凭据不可用。如果在谷歌计算引擎中运行,它们是可用的。否则,必须定义指向定义凭据的文件的环境变量GOOGLE\u APPLICATION\u CREDENTIALS

我这样设置环境变量:

export GOOGLE_APPLICATION_CREDENTIALS=“/home/me/*****.json”

com.google.cloud
谷歌云对话流
0.99.0-alpha
公共类应用程序{
公共静态void main(字符串[]args)引发异常{
字符串projectId=“我的项目id”;
String sessionId=“用于测试的假会话”;
String languageCode=“fr”;
List text=Arrays.asList(“hello”、“Qui-tu-es”);
映射结果=DetectionEntText(projectId、Text、sessionId、languageCode);
result.forEach((s,q)->System.out.println(s+“”+q));
}
公共静态地图检测文本(
字符串投影,
列出文本,
字符串sessionId,
字符串语言代码)引发异常{
Map queryResults=newhashmap();
//实例化客户机
try(sessionclient sessionclient=sessionclient.create()){
//使用sessionId(UUID)和projectID(我的项目id)设置会话名称
SessionName session=SessionName.of(projectId,sessionId);
System.out.println(“会话路径:+Session.toString());
//检测每个文本输入的意图
用于(字符串文本:文本){
//设置查询的文本(hello)和语言代码(en-US)
TextInput.Builder TextInput=TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
//使用TextInput构建查询
QueryInput QueryInput=QueryInput.newBuilder().setText(textInput.build();
//执行检测意图请求
DetectinentResponse response=SessionClient.Detectinent(会话,queryInput);
//显示查询结果
QueryResult QueryResult=response.getQueryResult();
System.out.println(“==================================”);
System.out.format(“查询文本:'%s'\n',queryResult.getQueryText());
System.out.format(“检测到的意图:%s(置信度:%f)\n”,
queryResult.getIntent().getDisplayName(),queryResult.getIntentDetectionConference());
System.out.format(“履行文本:'%s'\n',queryResult.getFulfillmentText());
put(文本,queryResult);
}
}
返回查询结果;
}
}
<dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-dialogflow</artifactId>
      <version>0.99.0-alpha</version>
</dependency>