简体   繁体   中英

Play framework config include breaks with dist

We have a complex application built using the play framework. The application is divided into distinct parts. The website, the crawlers and all the others use similar classes and configuration files. To remedy with that, we centralized these into a folder at the root of the play application.

In development, the import statement for the classes and the include statement, to load multiple config files, work fine. In production, we used to deploy the dist version of the code, but the includes, which all have relative paths, stopped to work.

We tried -Dconfig.file to load the parent. That file was added to the generated zip folder, but the included files were no where to be found.

Would anyone have an idea on how to "compile" or centralize the config files for play to load them all ?

Thank you for your help.

I had the same issue, I found that I had to specify the full path for the -Dconfig.file so the include part in it would work.

ie

/path/to/dir -->
     production.conf = {include "application.conf" and some overrides}
     start
     my-app/

./start -Dconfig.file=/path/to/dir/production.conf

edit in play 2.2 the distributable zip structure changed, there's now a bin dir with the app name script in it, so:

    /path/to/dir -->
     production.conf = {include "application.conf" and some overrides}
     bin/my-app

     ./bin/my-app -Dconfig.file=/path/to/dir/production.conf

So I didn't understand clearly how this works, but I will try to explain the big picture.

To allow multiple projects to use "external" config files we created another project. This new project is a sort of library. It holds all the objects used in multiple projects and the config files.

Each project has this "core" project as a dependency. This allows play, when we ask it to create the a distribution package, to merge all the code in one zip file.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM