[2.1.0] application.conf in sub-project

472 views
Skip to first unread message

Nicolas Forney

unread,
Mar 18, 2013, 7:16:05 AM3/18/13
to play-fr...@googlegroups.com
Hello,

Is there a way to define in a subproject an appliction.conf and then be able to access it from the subproject?

my-application
 |-- app
 |-- public
 |-- conf
 |  |-- application.conf
 |  `-- routes
 `-- modules
    `-- common
       |-- app
       |-- public
       |-- conf
         |-- application.conf   <-- 
         `-- common.routes
 

I created 
my-application/modules/common/conf/application.conf

and added a configuration :
 my.configuration="hello world"

Now i would like to access it from one of the common module controller.
 Play.application().configuration().getString("my.configuration"); 

But it doesn't works ecause the application.conf is not loaded.


Thx for your help

Manuel Bernhardt

unread,
Mar 18, 2013, 10:30:48 AM3/18/13
to play-fr...@googlegroups.com
Hi,

AFAIK this is not possible, Play (or Typesafe Config) will try to
locate an application.conf resource on the classpath and use that one.
I suppose you could use Typesafe Config directly and do something like

ConfigFactory.parseFile( ... )

and then wrap it in the Play wrapper of the Configuration (I don't
know if there is one for Java; I know there is one for Scala).

Manuel
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to play-framewor...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Nicolas Forney

unread,
Mar 19, 2013, 8:28:38 AM3/19/13
to play-fr...@googlegroups.com
Hi Manuel,

Thanks for the tips. I will check if I can use the ConfigFactory

Pedro Flores

unread,
Jul 8, 2014, 3:25:20 PM7/8/14
to play-fr...@googlegroups.com
Sorry to bring this up more than a year later, but I found this tutorial of submodules with play 2.1 having a application.conf in both the main project and the submodules:

http://manuel.bernhardt.io/2013/03/26/multi-modular-development-with-play-2-1/

Hope this helps someone.

Regards.

Pedro Flores
Reply all
Reply to author
Forward
0 new messages