【发布时间】:2015-10-28 11:10:58
【问题描述】:
我正在为 Scala 和 SBT 0.13.5 使用 Play 2.3.9。我使用替代配置运行我的测试,即
sbt -Dconfig.resource=test-application.conf test
即使它位于/conf,Play 也找不到此配置。我尝试不使用.conf 扩展名并将其放在不同的目录中。最后,我使用了已知的工作 application.conf 并失败了。似乎没有什么能满足它。但是,当我使用-Dconfig.file=/path/to/test-application.conf 时,Play 设法选择了配置文件。 -Dconfig.resource 我在这里缺少什么? -Dconfig.resource 甚至可以工作吗?谢谢。
【问题讨论】:
-
如果包含 test-application.conf 的文件夹在类路径中,请检查您的 build.sbt。
-
试试
activator -Dconfig.resource=test-application.conf test -
@mst test-application.conf 和 application.conf 位于 conf/.我知道 conf/ 是类路径路径的一部分。
-
@SteveChaloner 结果是一样的。在 Activator 启动期间引发错误。它找不到
test-application.conf和application.conf。 -
OTH,将
fork设置为true和-Dconfig.resource作为javaOptions在build.sbt内工作。如果没有分叉,SBT 不会捡起它。严格来说,javaOptions仅适用于fork设置为true,如上所述 [这里][1] 不过,奇怪的是,-Dconfig.resource在我原来的问题中 不起作用 与命令行即使test-application.conf在类路径之一中。 [1]:stackoverflow.com/questions/19060623/…
标签: scala unit-testing playframework