我们有一个使用 play 框架构建的复杂应用程序。该应用程序分为不同的部分。网站、爬虫和所有其他工具都使用类似的类和配置文件。为了解决这个问题,我们将它们集中到 Play 应用程序根目录下的一个文件夹中。
在开发中,类的 import 语句和 include 语句加载多个配置文件,工作正常。在生产中,我们过去常常部署代码的 dist 版本,但是所有具有相对路径的包含停止工作。
我们尝试了 -Dconfig.file 来加载父级。该文件已添加到生成的 zip 文件夹中,但找不到包含的文件。
有人知道如何“编译”或集中 Play 配置文件以加载它们吗?
感谢您的帮助。
最佳答案
我遇到了同样的问题,我发现我必须为 -Dconfig.file 指定完整路径,这样其中的 include 部分才能工作。
即
/path/to/dir -->
production.conf = {include "application.conf" and some overrides}
start
my-app/
./start -Dconfig.file=/path/to/dir/production.conf
编辑 在 play 2.2 中,可分发的 zip 结构发生了变化,现在有一个包含应用程序名称脚本的 bin 目录,因此:
/path/to/dir -->
production.conf = {include "application.conf" and some overrides}
bin/my-app
./bin/my-app -Dconfig.file=/path/to/dir/production.conf
关于scala - Play Framework 配置包括与 dist 的中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16874657/