Nee*_*mal 11 java jdbc amazon-web-services playframework aws-secrets-manager
我正在尝试在java play框架中实现aws秘密管理器。我按照本文https://www.geekyhacker.com/2020/05/09/getting-database-credentials-from-aws-secrets-manager-in-spring-boot/中的步骤首先在springboot中实现它工作完美。
现在,我在 play 框架中遵循相同的步骤。
第1步:我在build.sbt中添加了以下依赖项
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-java-sdk" % "1.12.122",
"com.amazonaws.secretsmanager" % "aws-secretsmanager-jdbc" % "1.0.6",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.12.2"
)
Run Code Online (Sandbox Code Playgroud)
其他相关依赖项包括:
libraryDependencies ++= Seq(
"mysql" % "mysql-connector-java" % "8.0.21"
)
libraryDependencies ++= Seq(
javaJpa,
"org.hibernate" % "hibernate-core" % "5.4.21.Final", // it is JPA implementation
"javax.validation" % "validation-api" % "2.0.1.Final" // added this because an issue was coming while running
)
Run Code Online (Sandbox Code Playgroud)
步骤2:更新conf文件
旧配置(运行良好)
play.db {
default = unclassified
}
base_db_url = "jdbc:mysql://{my_rds_endpoint}/"
db_annotations= "?createDatabaseIfNotExist=true"
base_db_user_name= "{rds_user_name}"
base_db_password= "{rds_password}"
db {
unclassified.driver = com.mysql.cj.jdbc.Driver//com.mysql.cj.jdbc.Driver
unclassified.jndiName = UnclassifiedDS
unclassified.url= ${base_db_url}"unclassified_"${serverEnvironment}${db_annotations}
unclassified.username=${base_db_user_name}
unclassified.password=${base_db_password}
}
Run Code Online (Sandbox Code Playgroud)
新配置:
play.db {
default = unclassified
}
base_db_url = "jdbc-secretsmanager:mysql://{my-rds-endpoint}/"
db_annotations= "?createDatabaseIfNotExist=true"
base_db_user_name= "{secret-name in secret manager}"
db {
unclassified.driver=com.amazonaws.secretsmanager.sql.AWSSecretsManagerMySQLDriver
unclassified.jndiName = UnclassifiedDS
unclassified.url= ${base_db_url}"unclassified_"${serverEnvironment}${db_annotations}
unclassified.username=${base_db_user_name}
}
Run Code Online (Sandbox Code Playgroud)
但出现错误:配置错误[无法初始化数据库] 原因:java.lang.IllegalArgumentException:需要dataSource或dataSourceClassName或jdbcUrl。
有人能帮我一下吗?
| 归档时间: |
|
| 查看次数: |
729 次 |
| 最近记录: |