如何在Play框架中不监视文件的更改 [英] How to not watch a file for changes in Play Framework

查看:97
本文介绍了如何在Play框架中不监视文件的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 sbt-buildinfo 创建一个BuildInfo.scala的Play Framework 2.2项目中编译项目时的文件,如何配置build.sbt以便Play Framework不会监视BuildInfo.scala文件的更改,并且如果该文件更改也不会重新启动服务器?

On a Play Framework 2.2 project that is using sbt-buildinfo to create a BuildInfo.scala file when the project is compiled, how can build.sbt be configured so that Play Framework won't watch the BuildInfo.scala file for changes, and won't restart the server if that file changes?

例如,如果会话开始于:

For instance, if a session is started with:

$ sbt ~run

,服务器以开发模式启动,然后在另一个终端窗口中启动另一个sbt会话(以运行另一个子项目,或仅运行其他sbt任务),第二个sbt会话将更新BuildInfo.scala文件,并且第一个sbt会话将检测到该文件并重新加载Play项目.

and the server starts in development mode, and then in another terminal window another sbt session is started (to run another subproject, or just to run other sbt tasks), this second sbt session will update the BuildInfo.scala file, and the first sbt session will detect this and reload the Play project.

所以问题是如何将BuildInfo.scala从监视中排除(但仍将其编译并包含在分发包中).

So the question is how to exclude BuildInfo.scala from monitoring (but still compile it and include it in the distribution package).

显然,watchSources配置选项可以提供帮助,但是在阅读了文档之后,我不知道如何使用它来排除文件.

Apparently the watchSources configuration option could help, but after reading the documentation I couldn't figure out how to use it to exclude a file.

推荐答案

要删除某个特定文件,可以在build.sbt中进行操作:

To remove a particular file from being watched you can do in build.sbt:

watchSources := watchSources.value.filter { _.getName != "BuildInfo.scala" }

我试图重现基本设置,但对我而言,BuildInfo.scala文件未被监视.您可以通过发出show watchSources来查看受监视来源的列表.

I tried to reproduce basic setup, and for me the BuildInfo.scala file is not watched. You can see the list of watched sources by issuing show watchSources.

这篇关于如何在Play框架中不监视文件的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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