[英]Access Play Configuration in Plain Scala Module
我有一個Play應用,我想細分為:
rest-播放模塊,其中包含rest接口
服務-包含角色和外部服務客戶端的純Scala模塊(例如S3)
我想創建一個S3Client對象類,但是在實例化它時,我需要從application.conf中讀取配置值。 since this is not a play module. 我不能使用因為這不是播放模塊。
我在想這個錯嗎? 實現我想要的最優雅的方法是什么?
只需使用typesafe Config工廠
import com.typesafe.config.ConfigFactory
val conf = ConfigFactory.load("/path/to/your/conf/file/application.conf")
//init your object with the conf file.
您甚至不需要在其中放置路徑。
如果application.conf
在根目錄中,則config factory
將自動檢查它是否在該目錄中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.