播放规格时配置中断,因为"There is no started application"



我在application.conf上将一些字符串外部化到 HOCON。我正在访问这样的配置值:

import play.api.Play.current
import play.api.Play.configuration
configuration.getString("foo.bar").get()
尽早,在

丢失密钥的情况下快速失败,就像文档所说的那样。

现在,我的一些依赖于已配置对象的测试失败,堆栈跟踪指出:

Caused by: java.lang.RuntimeException: There is no started application

我认为这与配置有关?我该如何解决这个问题?(测试是规格2)

你有FakeApplication吗?如文档中所述:http://www.playframework.com/documentation/2.0/JavaTest 运行测试/测试方法之前?

来自维基的例子:

@Test
public void findById() {
   running(fakeApplication(), new Runnable() {
      public void run() {
        Computer macintosh = Computer.find.byId(21l);
        assertThat(macintosh.name).isEqualTo("Macintosh");
        assertThat(formatted(macintosh.introduced)).isEqualTo("1984-01-24");
       }
   });
}

如果这不能解决您的问题,也许从堆栈跟踪提供更多信息会有所帮助。

编辑:请仔细标记您的问题,提及playframeworkplayframework-2.0是没有意义的

相关内容

最新更新