[英]BigQuery: How to load library into java code
I am a new dev in Bigquery.我是 Bigquery 的新开发人员。 I am following tutorial in https://developers.google.com/bigquery/bigquery-api-quickstart with Java code and imported library from https://developers.google.com/bigquery/client-libraries .
我正在关注https://developers.google.com/bigquery/bigquery-api-quickstart 中的教程,其中包含 Java 代码和从https://developers.google.com/bigquery/client-libraries导入的库。 However, I couldn't load library into Java code such as
import com.google.api.services.bigquery.model.DatasetList; import com.google.api.services.bigquery.model.GetQueryResultsResponse; import com.google.api.services.bigquery.model.Job
但是,我无法将库加载到 Java 代码中,例如
import com.google.api.services.bigquery.model.DatasetList; import com.google.api.services.bigquery.model.GetQueryResultsResponse; import com.google.api.services.bigquery.model.Job
import com.google.api.services.bigquery.model.DatasetList; import com.google.api.services.bigquery.model.GetQueryResultsResponse; import com.google.api.services.bigquery.model.Job
import com.google.api.services.bigquery.model.DatasetList; import com.google.api.services.bigquery.model.GetQueryResultsResponse; import com.google.api.services.bigquery.model.Job
Please tell me know how to solve this case. import com.google.api.services.bigquery.model.DatasetList; import com.google.api.services.bigquery.model.GetQueryResultsResponse; import com.google.api.services.bigquery.model.Job
请告诉我如何解决这个案例。
Thanks谢谢
You need to add the necessary .jar
files (separated by :
) to your classpath, ie您需要将必要的
.jar
文件(以:
分隔)添加到您的类路径中,即
javac -cp path/to/jar1:path/to/jar2 <your_class.java>
java -cp path/to/jar1:path/to/jar2 <your_class>
alternatively you can add the .jar
files to the CLASSPATH
environment variable, ie (in unix systems)或者,您可以将
.jar
文件添加到CLASSPATH
环境变量中,即(在 unix 系统中)
export CLASSPATH=$CLASSPATH:/path/to/some.jar:/path/to/some/other.jar
This can change depending on your environment (ie if you are running these in a webapp server)这可能会根据您的环境而改变(即,如果您在 webapp 服务器中运行这些)
if you are using maven this is done easily with the following 2 dependence (you can changes the version to the latest one)如果您使用的是 maven,这很容易通过以下 2 个依赖完成(您可以将版本更改为最新版本)
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev12-1.19.0</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-bigquery</artifactId>
<version>v2-rev168-1.19.0</version>
</dependency>
Are you using Maven and the BigQuery Java Client?您在使用 Maven 和 BigQuery Java 客户端吗? It is recommended to use the Java client.
推荐使用Java客户端。 If so, you can easily set it up by configuring your pom.xml file:
如果是这样,您可以通过配置 pom.xml 文件轻松设置它:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.111.1</version>
</dependency>
More info on the BigQuery Java client: https://github.com/googleapis/java-bigquery有关 BigQuery Java 客户端的更多信息: https : //github.com/googleapis/java-bigquery
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.