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

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

问题描述

默认情况下,只有在您对它执行http请求后,您的Play应用程序才会完全启动(已编译,GlobalonStart等).

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中.模式.尽管如此,我仍然需要禁用它,尽管这仅与在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 Task",然后在"Tasks"部分中输入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天全站免登陆