java - 大查询 API 异常
问题描述
我有这个问题
java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
在使用 Google 的 Big Query API 时。
我正在使用 JSF,GlassFish 4.1。
我的方法抛出异常:
public void process() throws InterruptedException, FileNotFoundException, IOException {
GoogleCredentials credentials;
File credentialsPath = new File("/home/jesus_miranda/Downloads/credential2.json"); // TODO: update to your key path.
try (FileInputStream serviceAccountStream = new FileInputStream(credentialsPath)) {
credentials = ServiceAccountCredentials.fromStream(serviceAccountStream);
}
// Instantiate a client.
BigQuery bigquery = BigQueryOptions.newBuilder().setCredentials(credentials).build().getService();
String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;";
QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query).build();
for (FieldValueList row : bigquery.query(queryConfig).iterateAll()) {//At this line the program failed.
for (FieldValue val : row) {
System.out.printf("%s,", val.toString());
}
System.out.printf("\n");
}
}
请帮助我,我阅读了很多论坛,所有这些都谈到了番石榴版本。我更新并降级了番石榴版本,它仍然无法正常工作。
问候!
解决方案
这个问题似乎是版本不匹配的结果。查看 BigQuery API 的依赖声明并查看正在使用的 Guava 版本。
也许您正在构建您的应用程序并忘记在您的 jar 中遮蔽/fatjar guava。
推荐阅读
- sql-server - SQL Server 排序顺序中带有“带”字母的错误排序顺序字符串
- c# - 如何避免Winform服务总线消息接收器中的跨线程操作无效异常
- c# - 从 Unity 构建中恢复检查器值
- node.js - 如何从 NodeJS 调用 FastAPI 路由?
- r - 在 R 中使用过滤器功能。需要为赛马数据库分配 NA 并保持数据集的长度相同
- amazon-web-services - AWS ECS 实例缺少“ecs.capability.efsAuth”属性
- laravel - 是否可以在 laravel 7.x 中使用 create-react-app
- c# - Word OpenXML 目录中的行数可以确定吗
- codenameone - 如何使用选择器创建一个弹出窗口,其中选择器立即处于活动状态并带有“跳过”选项?
- c# - 如何在两个 HierarchicalDataTemplates 中间添加一个 TreeViewItem?