Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.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 使用JAR从FIRESTORE数据库删除文档失败_Java_Firebase_Google Cloud Firestore - Fatal编程技术网

Java 使用JAR从FIRESTORE数据库删除文档失败

Java 使用JAR从FIRESTORE数据库删除文档失败,java,firebase,google-cloud-firestore,Java,Firebase,Google Cloud Firestore,我正在处理一个非常奇怪的问题 我有一个在IntelliJ上开发的代码,它试图从FireStore数据库中删除一个文档 当我在IntelliJ内部运行main时,没有问题 但是当我创建这个项目的JAR并以java-JAR xxxxx.JAR的形式运行这个JAR时,我得到了以下错误: Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.direc

我正在处理一个非常奇怪的问题

我有一个在IntelliJ上开发的代码,它试图从FireStore数据库中删除一个文档

当我在IntelliJ内部运行main时,没有问题

但是当我创建这个项目的JAR并以java-JAR xxxxx.JAR的形式运行这个JAR时,我得到了以下错误:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
        at com.google.api.gax.retrying.BasicRetryingFuture.<init>(BasicRetryingFuture.java:77)
        at com.google.api.gax.retrying.CallbackChainRetryingFuture.<init>(CallbackChainRetryingFuture.java:62)
        at com.google.api.gax.retrying.ScheduledRetryingExecutor.createFuture(ScheduledRetryingExecutor.java:84)
        at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:61)
        at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:41)
        at com.google.api.gax.rpc.UnaryCallable$1.futureCall(UnaryCallable.java:126)
        at com.google.api.gax.rpc.UnaryCallable.futureCall(UnaryCallable.java:87)
        at com.google.cloud.firestore.FirestoreImpl.sendRequest(FirestoreImpl.java:327)
        at com.google.cloud.firestore.UpdateBuilder.commit(UpdateBuilder.java:608)
        at com.google.cloud.firestore.WriteBatch.commit(WriteBatch.java:41)
        at com.google.cloud.firestore.DocumentReference.delete(DocumentReference.java:335)
        at main.main(main.java:26)
我正在编写用于删除文档的代码:

FileInputStream serviceAccount = new FileInputStream("./ServiceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder().setCredentials(GoogleCredentials.fromStream(serviceAccount)).build();
FirebaseApp.initializeApp(options);
Firestore db ;
CollectionReference to_be_Deleted ;



db = FirestoreClient.getFirestore();
ApiFuture<WriteResult> writeResult = db.collection("XXXXXX").document("WW4ovZ5amD56pxjd5NwY").delete();
System.out.println("Update time : " + writeResult.get().getUpdateTime());
关于这个问题,我真的需要帮助。我希望有人能告诉我我的错误


谢谢大家。

我遇到了一个类似的问题,我通过将番石榴-jdk5从构建中排除而解决了这个问题

// Exclude guava-jdk5 from the dependencies in gradle.
// guava-jdk5 uses older versions of classes that do not contain all required methods, as a later version of guava is in the project, excluding will mean it is used instead.
    configurations {
      all*.exclude group: 'com.google.guava', module:'guava-jdk5'
    }

在完成以下操作后,它现在对我有效。在IntelliJ中,我执行了文件>无效缓存/重新启动。然后我重建了.jar文件并成功运行


当我第二次遇到这个问题时,我也从零开始删除并重建了我的.jar。

我看到了类似的错误。我正在查询在IntelliJ中运行但在Build.jar中失败的文档集合,错误为:java.lang.NoSuchMethodError:com.google.common.util.concurrent.MoreExecutors.directExecutor。不幸的是,这没有为我修复错误。我仍然看到错误消息。java.lang.NoSuchMethodError:com.google.common.util.concurrent.MoreExecutors.directExecutor
// Exclude guava-jdk5 from the dependencies in gradle.
// guava-jdk5 uses older versions of classes that do not contain all required methods, as a later version of guava is in the project, excluding will mean it is used instead.
    configurations {
      all*.exclude group: 'com.google.guava', module:'guava-jdk5'
    }