问题
I'm running a Play framework application on a VirtualBox VM with the project source code in a directory shared from the host system. The auto-reload functionality of the framework doesn't work.
This is (probably) caused by JNotify being unable to detect the changes to the source files, as the filesystem is not local. Both NFS and vboxsf suffer from the same issue.
Is there any way around this?
Play framework has a built-in fallback mechanism for detecting changes on systems where JNotify is not available. Is it possible to force select the fallback mechanism somehow? (The performance hit would be acceptable.)
Any other solutions?
回答1:
I ran into the same situation here. Switching to ~run
(instead of run
), within the Play/SBT console, bypasses JNotify (according to Josh Suereth) and appears to solve the problem for me.
回答2:
Answering my own question: there doesn't seem to be a straightforward way to achieve this, and it doesn't look like this sort of functionality will become available in network filesystem in the near future.
It is rather trivial to hack the Play framework's sbt plugin and make the PlayReloader trait behave as if JNotify wasn't available, but that's a dirty hack to say the least.
The best solution seems to be to just move the Play application off the VM and run it on the host, even if some some of the benefits of fully automatically provisioned development environments are lost.
回答3:
According to James Roper, you can add the following to your build.sbt if you are using play 2.3.2 or later:
PlayKeys.playWatchService := play.sbtplugin.run.PlayWatchService.sbt(pollInterval.value)
Here is the link for James Roper's full response on this issue.
来源:https://stackoverflow.com/questions/14299300/auto-reloading-with-play-framework-on-a-network-filesystem