微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决无法从 springboot 应用程序连接到 AWS S3

我们正在开发 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

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

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

解决方法

有一些 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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。