Domanda

I have a Play app that I want to split into:

  • rest - Play module that holds the rest interface

  • services - plain Scala module that holds actors and external services clients (ex S3)

I want to create a S3Client object class, but when instantiating it I need to read the config values from application.conf. I can not use play.api.Play.current.configuration since this is not a play module.

Am I thinking this wrong? What would be the most elegant way to achieve what I want?

È stato utile?

Soluzione

just use typesafe Config factory

   import com.typesafe.config.ConfigFactory

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

   //init your object with the conf file.

Altri suggerimenti

You don't even need to put a path in it.

If the application.conf is in the root directory, the config factory will automatically check if it's there.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top