我有麻烦,包括在一个外部文件application.conf
我的戏2.1.1应用在生产模式(当推出start
)
在官方文档之后,我在application.conf
添加了一个include
语句:
[...]
include "/absolute/path/to/external/config/file.conf"
内容以这种方式加载:
configuration.getConfig("some-key")
它在开发模式下工作正常,但在生产模式下失败(它总是None
)。
这使我无法将我的应用程序部署到生产环境中。
任何帮助/想法将不胜感激。
编辑:按照Saffron的评论,我尝试了一些解决方法。
从include语句中删除第一个斜杠不起作用。
通过-Dconfig.file = / abs / path加载配置文件给出了奇怪的结果,似乎Play的行为不一致:
play start -Dconfig.file=/path/to/file.conf
不起作用。 然而启动play
然后运行start -Dconfig.file=/path/to/file.conf
确实有效?? !!
所以我最终创建了一个新的配置,而不是使用Play的:
val conf = ConfigFactory.parseFile(new File("/path/to/file.conf")).resolve()
val myValues = new Configuration(conf).getConfig("some-key").get
希望它可以帮助遇到同样问题的人。
我有一个问题,我的图像在prod模式下没有正确显示,但在开发模式下没问题。 解决方案是将路径写为(“images / ...”)而不是(“/ images / ...”)。 尝试一下,只是为了科学。
无论如何,如果这不起作用,这里有一些关于prod模式中的其他Conf的文档,控制台行覆盖文件。 $ start -Dconfig.file=/opt/conf/prod.conf
http://www.playframework.com/documentation/2.0/ProductionConfiguration