播放基于环境的框架,覆盖"application.conf"值 [英] Play framework overriding `application.conf` values based on environment
问题描述
播放2.6.x Scala
Play 2.6.x Scala
我在文件夹{project}/conf/
中有一个默认的application.conf
,但我想通过将相应的文件作为命令行参数传入(
I have a default application.conf
within the folder {project}/conf/
but I'd like to override some values depending on the environment by passing in the respective file as command-line arguments (as detailed in the docs):
sbt run -Dconfig.file=/conf/qa.conf
或sbt run -Dconfig.resource=qa.conf
但是我无法发挥自己的作用.这是我的文件目录:
But I'm not able to get play to pick up the overrides. Here's my file directory:
application
|- playApp1
|- playApp2
|-- conf
|-- application.conf
|-- qa.conf
我的build.sbt
使playApp2成为加载时的默认项目.而且我已经确认defulat application.conf
可以正常工作-只是覆盖无效.
My build.sbt
makes playApp2 the default project on load. And I have confirmed that the defulat application.conf
is working -- just the override is not.
感谢任何想法!
-
更新
这是播放中使用的HOCON文件. application.conf
Here are the HOCON files play uses. application.conf
platform {
scheme = "http"
host = "localhost:8080"
}
以及qa.conf
include "application.conf"
platform {
scheme = "https"
host = "ea311.34.com"
}
推荐答案
如果您首先提供命令行参数
This works if you provide the command line argument first
sbt -Dconfig.resource=qa.conf run
这篇关于播放基于环境的框架,覆盖"application.conf"值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!