简体   繁体   中英

import google-sample-code from github to java app

I would like to use the following function from google java-docs-samples in my code like this:

BigQueryUtils.getPages(...)

I added in pom.xml

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

and in my code:

import com.google.cloud.bigquery.samples;

public class MyClass {

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

i get this message:

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

how can I import above libraries in my project?

EDIT I also tried adding this on the pom, didnt help

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

I get this message in the pom:

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

The samples/examples are not part of the Maven central repo. As per the documentation , you would need to build the project yourself, and then include the local jar file that is built if you want to use those classes/methods:

  1. Clone/download the repo
  2. cd to bigquery
  3. mvn clean package -DskipTests
  4. Include the jar in your project

Bear in mind though, that these are just samples/examples. I wouldn't be depending on them for building solutions. They exist purely to guide and get people started with the APIs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM