0

我有一个要拆分的 Play 应用:

  • rest - 保存休息接口的播放模块

  • services - 简单的 Scala 模块,包含 actor 和外部服务客户端(例如 S3)

我想创建一个 S3Client 对象类,但是在实例化它时我需要从 application.conf 中读取配置值。我不能使用play.api.Play.current.configuration因为这不是一个播放模块。

我想错了吗?实现我想要的最优雅的方式是什么?

4

2 回答 2

1

只需使用类型安全的配置工厂

   import com.typesafe.config.ConfigFactory

   val conf = ConfigFactory.load("/path/to/your/conf/file/application.conf")

   //init your object with the conf file.
于 2014-03-17T14:26:17.393 回答
0

您甚至不需要在其中放置路径。

如果application.conf位于根目录中,config factory则会自动检查它是否存在。

于 2017-01-14T01:12:37.030 回答