无法从 springboot 应用程序连接到 AWS S3

时间:2021-01-05 14:00:44

标签: amazon-web-services spring-boot amazon-s3 aws-sdk-java

我们正在开发 Spring Boot 应用程序以连接 AWS S3。

  final AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);


        AmazonS3 s3client = AmazonS3ClientBuilder.standard()
                .withRegion(Regions.US_WEST_2)
                .withCredentials(new AWSStaticCredentialsProvider(credentials))
                .build();

在创建 AwsCredentials 对象行本身时,我们面临以下问题

java.lang.SecurityException: class "com.amazonaws.auth.BasicAWSCredentials"'s signer information does not match signer information of other classes in the same package

我们不明白问题出在哪里?

所以有人知道这是什么问题以及如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

有一些 AWS 教程讨论了如何从 Spring 启动应用程序与 Amazon S3 交互。

您的代码是 V1,所有 AWS 当前教程都是 V2。我建议使用适用于 AWS 版本 2 的 Java 开发工具包。

这是一个 AWS 教程,向您展示如何创建与 Amazon S3 交互的 Spring Boot 应用程序。除了 S3,此示例应用程序还使用以下 AWS 服务:

  • 亚马逊识别
  • 亚马逊 SES
  • AWS Elastic Beanstalk

要了解如何使用适用于 Java V2 的 AWS 开发工具包来开发调用 Amazon S3 和其他服务的 Spring Boot 应用程序,请参阅此 URL:https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/usecases/creating_photo_analyzer_app