java.lang.nosuchmethoderror:com.google.api.services.bigquery.model.jobconfigurationquery.getconnectionproperties()ljava/util/list;

i2loujxw  于 2021-06-27  发布在  Java
关注(0)|答案(1)|浏览(739)

我对com.google.api.services有一些问题。我正在使用这个版本“BigQueryAPI v2(修订版459)”:
https://www.javadoc.io/doc/com.google.apis/google-api-services-bigquery/v2-rev459-1.25.0/com/google/api/services/bigquery/model/jobconfigurationquery.html
实际上,方法“getconnectionproperties()”并不存在。。。这是完全错误:
线程“main”java.lang.nosuchmethoderror中出现异常:com.google.api.services.bigquery.model.jobconfigurationquery.getconnectionproperties()ljava/util/list;在com.google.cloud.bigquery.queryjobconfiguration$builder。java:250)在com.google.cloud.bigquery.queryjobconfiguration$builder。java:95)在com.google.cloud.bigquery.queryjobconfiguration.frompb(queryjobconfiguration。java:1060)在com.google.cloud.bigquery.jobconfiguration.frompb(作业配置。java:128)在com.google.cloud.bigquery.jobinfo$builderimpl。java:158)在com.google.cloud.bigquery.job.frompb(job。java:497)在com.google.cloud.bigquery.bigqueryimpl.create(bigqueryimpl。java:363)在com.google.cloud.bigquery.bigqueryimpl.create(bigqueryimpl。java:340)在bce\u datahub.bigquery\u template\u 0\u 1.bigquery\u template.tjava\u 1process(bigquery\u template)。java:383)在bce\u datahub.bigquery\u template\u 0\u 1.bigquery\u template.runjobintos(bigquery\u template)。java:757)在bce\u datahub.bigquery\u template\u 0\u 1.bigquery\u template.main(bigquery\u template。java:583)
我看到这个版本:
https://www.javadoc.io/doc/com.google.apis/google-api-services-bigquery/latest/com/google/api/services/bigquery/model/jobconfigurationquery.html
包含此方法,但如果将其替换为此版本,则会出现另一个错误:
noclassdeffounderror:com/google/api/services/bigquery/bigquery$builder
所以这个版本似乎没有这个类。
我正在开发一个java程序来:
对bigquery执行查询
在google云存储上导出bigquery表。
对于第二步,我没有问题。这些是我正在使用的jara:

我正在使用talend studio,所以我必须一个接一个地安装jar。这是生成问题的脚本的一部分:

  1. import java.io.File;
  2. import java.io.FileInputStream;
  3. import com.google.cloud.RetryOption;
  4. import com.google.cloud.bigquery.BigQuery;
  5. import com.google.cloud.bigquery.BigQueryException;
  6. import com.google.cloud.bigquery.BigQueryOptions;
  7. import com.google.cloud.bigquery.QueryJobConfiguration;
  8. import com.google.cloud.bigquery.Job;
  9. import com.google.cloud.bigquery.JobInfo;
  10. import com.google.cloud.bigquery.Table;
  11. import com.google.cloud.bigquery.TableId;
  12. import com.google.auth.oauth2.GoogleCredentials;
  13. import com.google.auth.oauth2.ServiceAccountCredentials;
  14. import com.google.auth.oauth2.AccessToken;
  15. import org.threeten.bp.Duration;
  16. //INPUT
  17. String credentialsPath = "...";
  18. String projectId = "...";
  19. String datasetName = "...";
  20. String tableName = "...";
  21. String bucketName = "...";
  22. String objectName = "...";
  23. String destinationUri = "...";
  24. String dataFormat = "...";
  25. String destFilePath = "...";
  26. String ddl =
  27. "DROP TABLE IF EXISTS `" + datasetName + "." + tableName + "`;"
  28. + "CREATE TABLE `" + datasetName + "." + tableName + "` AS "
  29. + "SELECT * FROM ...";
  30. //Authentification
  31. File credentialsFilePath = new File(credentialsPath);
  32. FileInputStream serviceAccountStream = new FileInputStream(credentialsFilePath);
  33. GoogleCredentials credentials;
  34. credentials = ServiceAccountCredentials.fromStream(serviceAccountStream);
  35. // Initialize client that will be used to send requests. This client only needs to be created
  36. // once, and can be reused for multiple requests
  37. BigQuery bigquery = BigQueryOptions.newBuilder()
  38. .setProjectId(projectId)
  39. .setCredentials(credentials).build()
  40. .getService();
  41. // Execute query on BigQuery
  42. QueryJobConfiguration config = QueryJobConfiguration.newBuilder(ddl).build();
  43. Job job = bigquery.create(JobInfo.of(config));
  44. Job completedJob =
  45. job.waitFor(
  46. RetryOption.initialRetryDelay(Duration.ofSeconds(1)), //Checking period time [Optional]
  47. RetryOption.totalTimeout(Duration.ofMinutes(3)) //Timeout [Optional]
  48. );
  49. if (completedJob == null)
  50. {
  51. System.out.println("Job not executed since it no longer exists.");
  52. return;
  53. } else if (completedJob.getStatus().getError() != null)
  54. {
  55. System.out.println("BigQuery was unable to execute the query due to an error: \n" + job.getStatus().getError());
  56. return;
  57. }
  58. System.out.println("Table create successful. Check in " + datasetName + " for the " + tableName + " table.");
  59. ...
wfypjpf4

wfypjpf41#

断然的。
我安装了我在https://mvnrepository.com/artifact/com.google.apis/google-api-services-bigquery/v2-rev20201030-1.31.0.
我不明白为什么我从这里下载的jarhttps://www.javadoc.io/doc/com.google.apis/google-api-services-bigquery/latest/com/google/api/services/bigquery/model/jobconfigurationquery.html
不起作用。

似乎他们是不同的。但是我解决了我的问题。

相关问题