简体   繁体   中英

IntelliJ can't find google-cloud-storage classes

I'm trying to use Google cloud storage and I'm following this guide: https://cloud.google.com/storage/docs/reference/libraries#using_the_client_library

I'm using Java with Maven, and this is my Pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.findwise.app</groupId>
    <artifactId>data-pipeline</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
          <groupId>com.google.cloud</groupId>
          <artifactId>google-cloud-pubsub</artifactId>
          <version>0.32.0-beta</version>
        </dependency>
        <dependency>
          <groupId>com.google.cloud.dataflow</groupId>
          <artifactId>google-cloud-dataflow-java-sdk-all</artifactId>
          <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-storage</artifactId>
            <version>1.70.0</version>
        </dependency>
    </dependencies>
</project>

As you can see I've added the google-cloud-storage dependency. My problem is that the classes used in the Java part of the guide ( Storage , StorageOptions , Bucket , BucketInfo ) are unfindable by IntelliJ. I can't import them. In fact, when I try to import via the absolute path:

import com.google.cloud.storage.Storage;

IntelliJ complains that the symbol google cannot be resolved. What is wrong here?

There are a few places to look:

  1. Find your local .m2 repository and navigate to the com.google.cloud dependencies. If you don't find it, or the JARs aren't there, IntelliJ won't be able to access them.
  2. IntelliJ will show you the External Libraries it is using under your source code in the project panel on the left.

If IntelliJ cannot import the class, it suggests that your Maven pull isn't working.

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