小编Mah*_*ary的帖子

从 AWS Secrets Manager 导入 Spring Boot 应用程序中的密钥

我使用该选项将 MySQL 数据库凭证存储在 AWS Secret Manager 中Credentials for other database。我想将这些凭据导入到我的application.properties文件中。根据我在该线程中找到的一些答案,我执行了以下操作:

  1. 添加了依赖spring-cloud-starter-aws-secrets-manager-config
  2. 添加spring.application.name = <application name>spring.config.import = aws-secretsmanager: <Secret name>application.properties
  3. 使用密钥作为以下属性中的占位符:
spring.datasource.url = jdbc:mysql://${host}:3306/db_name
spring.datasource.username=${username}
spring.datasource.password=${password}
Run Code Online (Sandbox Code Playgroud)

我在运行应用程序时收到以下错误:

java.lang.IllegalStateException: Unable to load config data from 'aws-secretsmanager:<secret_name>'
Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader. If the location is meant to reference a directory, it must end in '/' or File.separator
Run Code Online (Sandbox Code Playgroud)

首先,我遵循的流程正确吗?如果是,此错误与什么有关以及如何解决?

amazon-web-services spring-boot spring-cloud spring-cloud-config aws-secrets-manager

7
推荐指数
1
解决办法
2万
查看次数