Danny
Danny

Reputation: 161

maven cant find aws sdk for java

I'm a newbie on Java (with maven), and trying to integrate aws sdk for java with maven. I'm using Visual code for simplicity, and since its light-weight (plus, other IDE's are super confusing for me). Running on Mac OS Sierra.

I've done the below so far:

1) I already have maven

$mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T03:41:47+11:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"

2) Created new maven project

mvn archetype:generate 
    -DgroupId=com.domain.javalab 
    -DartifactId=javalab 
    -DarchetypeArtifactId=maven-archetype-quickstart 
    -DinteractiveMode=false

3) Added the below dependancy in pom.xml

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

4) Created the below test code (Only including the package and import section for now, for clarity)

package com.domain.javalab;

import java.io.File;
import java.io.IOException;

import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.StorageClass;
... Some Code ...

5) When I try to compile the code, I get "package com.amazonaws does not exist" error. I know it might be silly that some class-path or dependecy missing somewhere, but I just cant figure out where.

$ javac UploadObjectSingleOperation.java
UploadObjectSingleOperation.java:6: error: package com.amazonaws does not exist
import com.amazonaws.AmazonClientException;
                ^
UploadObjectSingleOperation.java:7: error: package com.amazonaws does not exist
import com.amazonaws.AmazonServiceException;
                ^
UploadObjectSingleOperation.java:8: error: package com.amazonaws.auth.profile does not exist
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
                             ^
UploadObjectSingleOperation.java:9: error: package com.amazonaws.services.s3 does not exist
import com.amazonaws.services.s3.AmazonS3;
.
.

running the 'mvn package' gives me build failure due to the above compilation error I guess.

I have even tried to execute the below to copy the dependency jars to local target/dependency folder.

$mvn dependency:copy-dependencies

Now I have the aws-sdk jar files in both main maven repository (under .m2/repository/ in user home directory) and under targets/dependency in local project directory.

I'm still trying to figure out the right way to do it. Everywhere I searched, it looks like adding the dependency in pom.xml would do the trick. Or am I missing anything, or out of sequence?

EDIT : Editing the question with version 1.11.271.

Adding pom.xml content below:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.domain.javalab</groupId>
  <artifactId>javalab</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>javalab</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk</artifactId>
      <version>1.11.271</version>
    </dependency>
  </dependencies>
</project>

Upvotes: 2

Views: 5083

Answers (1)

L Y E S  -  C H I O U K H
L Y E S - C H I O U K H

Reputation: 5080

My first remark is that the version 1.11.272 does not exist. see here

Upvotes: 0

Related Questions