在 Play 应用程序中禁用延迟加载 [英] Disabling lazy load in Play application

查看:19
本文介绍了在 Play 应用程序中禁用延迟加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,您的 Play 应用程序将完全启动(编译、GlobalonStart 调用等),只有在您向它发出 http 请求后.

By default your Play application will be fully started (compiled, Global's onStart called, etc.) only after you do http request to it.

有没有办法禁用这种延迟加载并使 Play 应用程序编译代码并在应用程序进程运行后启动?

Is there a way to disable this lazy load and make Play app compile code and do startup once application process is run?

PS:我使用的是 Play 2.3.

PS: I am using Play 2.3.

更新:正如 Ryan 指出的,延迟加载只发生在开发中.模式.尽管如此,我仍然需要禁用它,尽管这仅与在 dev 中运行的应用程序相关.模式.

UPDATE: As Ryan pointed out lazy load happens only in dev. mode. Nevertheless I still need to disable it, despite this is relevant only to apps running in dev. mode.

推荐答案

您可以使用 testProd 而不是 run(在当前 2.5 版本中)运行您的应用程序.这会以生产模式而不是开发模式启动您的应用程序.

You can run your application with testProd instead of run (in the current 2.5 version). This starts your application in prod mode instead of dev.

如果您从 IntelliJ 而不是 Play 控制台运行,您需要创建一个新的运行配置,选择 SBT 任务,然后在任务部分输入 testProd.

If you're running from IntelliJ rather than the Play console, you need to create a new run config, choose SBT Task, and in the Tasks section enter testProd.

这篇关于在 Play 应用程序中禁用延迟加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆