java - 需要有关 NoSuchMethodError : com. google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor 的帮助;在 IntelliJ 中

标签 java intellij-idea firebase-realtime-database google-cloud-firestore guava

还有一些其他问题,但其中大多数是针对 Android 的,我目前正在使用 Java Gradle 项目在 IntelliJ 中工作。

我的项目是 IntelliJ 中的 Gradle Java 项目,我使用 Cloud Firestore 作为数据库。我正在尝试创建一个 .jar 文件,以便可以运行该应用程序,但它引发了异常。

当我创建 .jar 文件时,我可能做错了什么,因为当我在 IntelliJ 中运行该应用程序时,它工作正常。当我运行 .jar 文件时出现问题。异常情况如下:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at io.grpc.internal.ClientCallImpl.<init>(ClientCallImpl.java:96)
at io.grpc.internal.ManagedChannelImpl$RealChannel.newCall(ManagedChannelImpl.java:662)
at io.grpc.internal.CensusTracingModule$TracingClientInterceptor.interceptCall(CensusTracingModule.java:382)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104)
at io.grpc.internal.CensusStatsModule$StatsClientInterceptor.interceptCall(CensusStatsModule.java:675)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104)
at com.google.api.gax.grpc.GrpcHeaderInterceptor.interceptCall(GrpcHeaderInterceptor.java:81)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104)
at com.google.api.gax.grpc.GrpcMetadataHandlerInterceptor.interceptCall(GrpcMetadataHandlerInterceptor.java:55)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104)
at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:636)
at com.google.api.gax.grpc.GrpcClientCalls.newCall(GrpcClientCalls.java:66)
at com.google.api.gax.grpc.GrpcDirectServerStreamingCallable.call(GrpcDirectServerStreamingCallable.java:65)
at com.google.api.gax.grpc.GrpcExceptionServerStreamingCallable.call(GrpcExceptionServerStreamingCallable.java:62)
at com.google.api.gax.rpc.WatchdogServerStreamingCallable.call(WatchdogServerStreamingCallable.java:69)
at com.google.api.gax.rpc.ServerStreamingCallable$1.call(ServerStreamingCallable.java:220)
at com.google.api.gax.rpc.ServerStreamingCallable$1.call(ServerStreamingCallable.java:220)
at com.google.api.gax.rpc.ServerStreamingCallable.serverStreamingCall(ServerStreamingCallable.java:166)
at com.google.api.gax.rpc.ServerStreamingCallable.serverStreamingCall(ServerStreamingCallable.java:178)
at com.google.cloud.firestore.FirestoreImpl.streamRequest(FirestoreImpl.java:339)
at com.google.cloud.firestore.Query.stream(Query.java:955)
at com.google.cloud.firestore.Query.get(Query.java:995)
at com.google.cloud.firestore.Query.get(Query.java:965)
at main.main(main.java:39)

main.java 中的第 39 行是:

ApiFuture<QuerySnapshot> query = db.collection("collectionName").get();

我读到 Guava 存在一些版本问题,但我无法排除 build.gradle 中的依赖项。我尝试了所有我发现的东西,但没有任何效果。

同样,当我在 IntelliJ 中运行 main 方法时,该项目工作正常,但当我运行 .jar 时,它会抛出异常。

如果我能收到一些有关如何创建 .jar 文件的提示,或者是否有关于 Guava 的任何有用信息以及如何修复依赖项,我将不胜感激。

最佳答案

也许您使用的是旧版本的 Guava。 com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor 自 Guava 18.0 起引入。

 * @since 18.0
 */
public static Executor directExecutor() {
  return DirectExecutor.INSTANCE;
}

另请参阅: https://github.com/google/guava/commit/495f60836c95faa28955a1183a92b0ecd3b50365#diff-7a493427c77df959295f1d55574dbd50

请检查build.gradle中Guava的依赖关系并尝试升级它。 如果您使用的不是旧版本,请在 IntelliJ 上点击 CTRL + N,然后输入 com.google.common.util.concurrent.MoreExecutors 找到您正在使用的 Guava jar 。

关于java - 需要有关 NoSuchMethodError : com. google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor 的帮助;在 IntelliJ 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51790294/

相关文章:

javascript - 在 firebase 中查询日期的 startAt 和 endAt

java - stax从元素中获取属性值

java - 潜在的空指针访问

java - Sonarqube SonarLint 定制

android - java.lang.ClassCastException : java. util.HashMap 无法转换为 Ride

android - 永远不会调用 Firebase populateViewHolder

java - 如何检查今天的日期是当月的第一天

java - 将 UTF-8 PDF 字体获取到用 Java/Spring 编译的 JasperReports 3.7.* 报告中

android - 第一次上传 Android studio 项目到 Subversion

intellij-idea - Intellij 未检测到 runConfigurations xml