gpt4 book ai didi

java - 将 google-sample-code 从 github 导入到 java 应用程序

转载 作者:行者123 更新时间:2023-12-01 09:02:43 24 4
gpt4 key购买 nike

我想使用 google java-docs-samples 中的以下函数在我的代码中是这样的:

BigQueryUtils.getPages(...)

我在pom.xml中添加了

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>0.5.1</version>
</dependency>

在我的代码中:

import com.google.cloud.bigquery.samples;

public class MyClass {

public static void method() {
BigQueryUtils.getPages(...);
}

我收到此消息:

 The import com.google.cloud.bigquery.samples cannot be resolved

如何在我的项目中导入上述库?

编辑我也尝试在 pom 上添加这个,但没有帮助

    <dependency>
<groupId>com.google.cloud</groupId>
<artifactId>doc-samples</artifactId>
<version>1.0.0</version>
</dependency>

我在 pom 中收到此消息:

Missing artifact com.google.cloud:doc-samples:jar:1.0.0

最佳答案

示例/示例不是 Maven 中央存储库的一部分。根据documentation ,您需要自己构建项目,然后 include the local jar file如果您想使用这些类/方法,则构建它:

  1. 克隆/下载 repo
  2. cd 到 bigquery
  3. mvn clean package -DskipTests
  4. 将 jar 包含在您的项目中

但请记住,这些只是示例/示例。我不会依赖他们来构建解决方案。它们的存在纯粹是为了指导和帮助人们开始使用 API。

关于java - 将 google-sample-code 从 github 导入到 java 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41546545/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com