【发布时间】:2022-01-18 20:54:15
【问题描述】:
我在 Spring Boot 应用程序上实现了 aws-secretsmanager-jdbc 库,就像 video 中介绍的那样。
按照说明操作后,我一直在努力解决这两个问题:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is com.amazonaws.services.secretsmanager.model.AWSSecretsManagerException: The security token included in the request is invalid. (Service: AWSSecretsManager; Status Code: 400; Error Code: UnrecognizedClientException; Request ID: 4880ebc0-59ed-49e6-abc5-6ba535e942eb; Proxy: null)
com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. (Service: AWSSecretsManager; Status Code: 400; Error Code: InvalidSignatureException; Request ID: 9a356a2b-b8fe-4810-ae28-08b1b9ec939d)
我google了很多,终于找到了解决办法:
- 对于第一个问题,我缺少设置 AWS 凭证环境变量:AWS_ACCESS_KEY_ID、AWS_SECRET_ACCESS_KEY 和 AWS_DEFAULT_REGION。 Spring Boot 应用程序需要这些变量才能连接到 AWS。
- 上一期,看了site之后才发现问题与设置正确的编码有关。因此,我尝试以这种方式运行应用程序:
java -jar app.jar -Dfile.encoding=UTF-8
它开始正常工作。我的代码可以在here 获得,如果你想看看的话。
Here 你可以找到在 IntelliJ 上设置编码的方法。
重要提示:
- 这不是一个问题。我只是想根据我在谷歌上搜索的内容添加一些知识,但没有找到任何可能的解决方案。
- 我向 Maciej 发送了一封电子邮件,他热情地回复并提出了一些建议。
【问题讨论】:
-
您使用的是AWS提供的Java SDK吗?
-
不,只是在 pom.xml (github.com/danielcasique/aws-secret-manager/blob/main/pom.xml) 中设置的依赖项。我来看看AWS提供的Java SDK。
-
@smac2020 这只是我在春季开始使用 aws secrets manager 的一个示例。可能还有更多...
-
我正在检查那个例子。它似乎不是官方 Java AWS 开发工具包。
-
是的,没错。 @maciejwalkowiak 也这么说。实际上,Maciej 说“库本身并没有由 AWS 积极维护”。无论如何,如果您有任何在 Spring Boot 应用程序上使用 aws Secrets Manager 的示例,我将不胜感激。
标签: spring amazon-web-services spring-boot aws-secrets-manager