出现此消息的原因是什么?“无法选择在Google Compute Engine上运行的我们。”

时间:2019-01-31 05:45:50

标签: google-cloud-platform google-translate

我是韩国人,希望我能听懂我的英语不好。

由于无法在环境变量中注册API密钥,因此在确认已将API密钥从TranslateOptions导入到getProperty后,使用setProperty注册了API密钥。

尽管可以成功运行,但TranslateOptions的初始化过程中发生了错误。

private static Translate translateSet;

static{
    System.setProperty("GOOGLE_API_KEY", "MY API KEY");
    translateSet = TranslateOptions.getDefaultInstance().getService();
}
public String translate(Object text, String target){
    String result = "";
    try{
        Translation translation = translateSet.translate(
        Fn.toString(text),//Object to String
        TranslateOption.sourceLanguage("ko"),
        TranslateOption.targetLanguage(target)
        );
        result = translation.getTranslatedText();
    }catch(Exception e){
        System.out.println(e.toString());
    }
    return result;
}

错误消息

----------------------------------------------------
1월 31, 2019 2:26:25 오후 com.google.auth.oauth2.ComputeEngineCredentials runningOnComputeEngine
정보: Failed to detect whether we are running on Google Compute Engine.
java.net.SocketException: Network is unreachable: connect

1월 31, 2019 2:26:25 오후 com.google.auth.oauth2.ComputeEngineCredentials runningOnComputeEngine
정보: Failed to detect whether we are running on Google Compute Engine.
java.net.SocketException: Network is unreachable: connect

1월 31, 2019 2:26:25 오후 com.google.auth.oauth2.ComputeEngineCredentials runningOnComputeEngine
정보: Failed to detect whether we are running on Google Compute Engine.
java.net.SocketException: Network is unreachable: connect

0 个答案:

没有答案