在 playframework 中重新加载自定义文件更改的应用程序 [英] Reload app on custom file change in playframework
问题描述
在 playframework 中有自动重新加载功能.这意味着在每个请求的开发模式下,play 检查文件的更改,并在必要时重新编译和重新加载项目.因此,例如,如果我 $ touch conf/routes
,项目将在下一次请求时重新加载.
In playframework there is auto-reload feature. It means that in development mode on each request play checks files on changes, and recompiles and reloads project if necessary. So, for example if I $ touch conf/routes
, project will be reloaded on next request.
我想添加一些自定义文件以供关注.
I'd like to add some custom file to watch for.
我相信 watchSources
设置包含正在播放的文件列表.但这对我不起作用.考虑一下,我们想将 trigger
文件添加到观看的源中.
I believe watchSources
setting contains list of files play is watching for. But it doesn't work for me. Consider, we want to add trigger
file to watched sources.
watchSources <+= baseDirectory map { _ / "trigger" }
已成功添加到观看源
[sbt console] $ show watch-sources
[info] List(/* trigger appears in list */)
但播放会忽略 trigger
更改并且不会重新启动应用程序.我错过了什么?如何让播放监视自定义文件更改?
But play ignores trigger
changes and doesn't restart application. What I am missing? How to make play watch for custom file changes?
推荐答案
我从来没有尝试过这样做,但经过调查,我注意到了
I've never tried to do this, but after investigating, I noticed that
watchSources <+= confDirectory map { _ / "routes" }
自然指向 conf (conf/routes) 中的路由文件.是不是忘了把文件trigger"放到conf(conf/trigger)中?
naturally points to the routes file in conf (conf/routes). Is it possible you forgot to put the file "trigger" in conf (conf/trigger)?
这篇关于在 playframework 中重新加载自定义文件更改的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!