Athul Muralidharan
Athul Muralidharan

Reputation: 753

How to fix this - Maven dependency added but import unresolved in intellij?

After a recent merge in a repo, the maven file was updated for adding aws bucket access.

 <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>1.9.2</version>
    </dependency>

The above dependency is present in my pom.xml file. But still, I am getting the following error :

cannot resolve symbol SDKGlobalConfiguration

for the following lines

import com.amazonaws.SDKGlobalConfiguration;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;

list of imports used :

import com.amazonaws.SDKGlobalConfiguration;
import com.amazonaws.auth.AWSCredentials
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.S3ObjectSummary;

Update : Updated the complete list of imports used below.

Upvotes: 1

Views: 5751

Answers (1)

AlexGera
AlexGera

Reputation: 783

It belongs to submodule.

Add more specific:

<dependency>
  <groupId>com.amazonaws</groupId>
  <artifactId>aws-java-sdk-core</artifactId>
  <version>1.9.2</version>
</dependency>

If you decided to use SDK version 1 you have to add dependencies for individual services as far as you don't import BOM.

Actually, BOM is recommended method. So add the following:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-bom</artifactId>
      <version>1.11.298</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

Upvotes: 2

Related Questions