Playframework 如何使用sbt start in Play应用程序指定配置文件?
我有一个开发和部署Play 2.3.6应用程序的常见用例:Playframework 如何使用sbt start in Play应用程序指定配置文件?,playframework,sbt,config,Playframework,Sbt,Config,我有一个开发和部署Play 2.3.6应用程序的常见用例: 在开发中,我运行sbt run,应用程序按预期使用application.conf 在生产中,我想使用sbt start并指定配置文件production.conf,它与dev config文件(即/conf/)位于同一目录中 按照上“指定替代配置文件”标题下的说明,如下所示: $ sbt start -Dconfig.file=/full/path/to/project/conf/production.conf 应用程序启动时没
- 在开发中,我运行
,应用程序按预期使用sbt run
application.conf
- 在生产中,我想使用
并指定配置文件sbt start
,它与dev config文件(即production.conf
)位于同一目录中/conf/
$ sbt start -Dconfig.file=/full/path/to/project/conf/production.conf
应用程序启动时没有错误,但我可以检查web应用程序,看到它正在加载我的application.conf
开发值,而不是production.conf
中的生产值
我还尝试了建议的方法:
$ sbt start -Dconfig.resource=production.conf
服务器无法启动,出现错误:
[error] com.typesafe.config.ConfigException$IO: production.conf: java.io.IOException: resource not found on classpath: production.conf
还有其他人知道如何正确地做这件事吗?浪费了几个小时后,我知道了。使用以下引号可正确传递参数:
$ sbt "start -Dconfig.resource=production.conf"
此外,如果需要指定端口号,请确保它位于配置选项之后,否则将忽略它:
$ sbt "start -Dconfig.resource=production.conf 9001"
也。。。我刚刚意识到,如果您指定端口号,它必须位于config选项之后,否则该选项将被忽略。我正在尝试使用play with default配置文件(application.conf),但我仍然有相同的问题。conf目录中有application.conf文件。但是,当我执行
sbt start
命令时,同样的错误也会出现,这对我很有效: