I want to use AWS S3 buckets with my Java 17 / Maven 3.8.5 app but when I add this to the pom.xml file
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.12.177</version>
</dependency>
I get a bunch of errors like these:
Failed to read artifact descriptor for com.amazonaws:aws-java-sdk-iotevents:jar:1.12.177
although when I add -core like this:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.12.177</version>
</dependency>
the errors go away in my pom.xml file but I dont think this is what I want.
What I want is to be able to import com.amazonaws.services.s3.AmazonS3; like this
import com.amazonaws.services.s3.AmazonS3;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AmazonConfig {
public AmazonS3 s3() {
AWSCredentials awsCredentials = new BasicAWSCredentials("", "");
}
}
but I keep getting this error
The import com.amazonaws.services.s3 cannot be resolved
Im really new to Java so I'm not sure if the problem is from my Maven configuration or something else.
Thanks.
CodePudding user response:
you may need to do a mvn install
or mvn package
, this way, you will download the dependency.
CodePudding user response:
First of all check if the dependencies are pulled or not in the external dependencies section in the IDE. If its not there see if maven is configured properly. What ide are you using? If its eclipse force a maven update on the project. If it’s Intellij, invalidate caches from the file menu. Close the ide. Open the root directory of you project in file explorer and Delete any .preferences or .setting or any other unnecessary file or folder present on the source folder reated by the ide and after clearing all that open up IDE and see if that resolves the issue.
Also for s3 you’ll need this dependency
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId></dependency>
CodePudding user response:
Really not sure what was wrong but restarting a new project worked.