Maven fails to find aws s3 sdk

Viewed 6858

Trying to set up a new project with the Amazon AWS Java SDK via Maven, and apparently Maven can't find the s3 package.

This is the error:

[ERROR] /X:/java/amazon/S3/s3shell/src/main/java/me/s3/S3Shell.java:[4,42] package software.amazon.awssdk.services.s3 does not exist

And these are the dependencies in the pom file:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>bom</artifactId>
    <version>2.2.0</version>
    <type>pom</type>
    <scope>import</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>s3</artifactId>
      <version>2.2.0</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
</dependencies>
</dependencyManagement>
3 Answers

For the record, the solution is:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>bom</artifactId>
            <version>2.2.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>s3</artifactId>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
          <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

replace existing one with the following and try(version can be changed)

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

The cleanest solution, if it can work, is as follow:

  1. mvn clean install, or
  2. Right click on pom.xml, Reload project.
Related