'Intellij Cannot access com.google.cloud.Service

I am writing a class to handle gcs bucket operations for my test framework. my code looks something like this

credentials = GoogleCredentials
                .fromStream(new FileInputStream("/path/to/key/file"));
 Storage storage = StorageOptions.newBuilder().setCredentials(credentials).setProjectId("projectID").build().getService();

However Intellij is throwing compile time error Cannot access com.google.cloud.Service.

My pom.xml looks something like this.

<?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.javalearning</groupId>
    <artifactId>Java</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>15</maven.compiler.source>
        <maven.compiler.target>15</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-storage</artifactId>
            <version>2.3.0</version>
        </dependency>

    </dependencies>

</project>

Any help will be appreciated. I have tried reload all maven project & invalidate cache and restart options.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source