如何在 application.conf 中外化 Cassandra 的配置属性?
How to externalize configuration properties of Cassandra in application.conf?
我发现对于Mongodb
,我可以在application.conf
中添加关于数据库的信息。
play.modules.enabled += "play.modules.reactivemongo.ReactiveMongoModule"
play.modules.enabled += "module.Module"
mongodb.uri = "mongodb://localhost:27017/demodb
Cassandra
也有类似的东西吗?我知道我可以在 Datastax
驱动程序的代码中提及数据库名称、端口、IP 等,但我无法在 application.conf
.
中找到有关执行相同操作的信息
您始终可以使用 Scala Configuration API to externalize properties. As the documentation states, Play relies on Lightbend's config library. Thus, simply specify all your details in a .conf
file by using the HOCON,然后稍后在您的代码中检索属性。
我发现对于Mongodb
,我可以在application.conf
中添加关于数据库的信息。
play.modules.enabled += "play.modules.reactivemongo.ReactiveMongoModule"
play.modules.enabled += "module.Module"
mongodb.uri = "mongodb://localhost:27017/demodb
Cassandra
也有类似的东西吗?我知道我可以在 Datastax
驱动程序的代码中提及数据库名称、端口、IP 等,但我无法在 application.conf
.
您始终可以使用 Scala Configuration API to externalize properties. As the documentation states, Play relies on Lightbend's config library. Thus, simply specify all your details in a .conf
file by using the HOCON,然后稍后在您的代码中检索属性。