OSX 播放框架自动重新加载

OSX Play Framework Auto-Reload

我已经在互联网上搜索了几个小时了,有很多 "helpful" 建议...除了问题什么都没有。

这就是我,几乎完全一样:

Play framework auto-loading in docker container

我是 运行 Play 的最新版本(我想,不知道如何查看,但已下载 <一周前)! ubuntu docker 容器内的框架 Java 8,使用以下 docker 文件构建:

FROM ubuntu:latest
MAINTAINER [REDACTED]
RUN sudo apt-get update
RUN sudo apt-get -y install software-properties-common
RUN sudo apt-add-repository ppa:webupd8team/java
RUN sudo apt-get update
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
RUN sudo apt-get -y install oracle-java8-installer
RUN java -version

Multiple sources across the internet show the same or similar issues, and more or less arrive at the same conclusion。我正在按如下方式启动我的游戏应用程序:

我不打算重复上面链接的内容,这基本上是相同的情况。 (检测到文件更改,它显示编译,尽管网页没有反映更改。)此外,我正在通过反编译生成的 .class 文件来验证正确的编译,它显示正确的代码。

现在,当我说出神奇的话语时:将以下行添加到我的 build.sbt 文件中

PlayKeys.playWatchService := play.sbtplugin.run.PlayWatchService.sbt(pollInterval.value)

我的总体 build.sbt 为:

name := """cms-work"""

version := "1.0-SNAPSHOT"

retrieveManaged := true

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs
)

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

// Polling for auto-reload, because networked filesystem.
PlayKeys.playWatchService := play.sbtplugin.run.PlayWatchService.sbt(pollInterval.value)

运行 ./activator 在我的项目目录中导致它重新评估我的构建文件并生成以下内容:

/root/cms-work/build.sbt:23: error: value playWatchService is not a member of object play.sbt.Play.autoImport.PlayKeys
PlayKeys.playWatchService := play.sbtplugin.run.PlayWatchService.sbt(pollInterval.value)
         ^
[error] Type error in expression

很明显,一刀切的解决方案不再适用。从那以后我就被难住了。自 2.3.x 以来,我完全没有发现任何会使此命令无效的更改。相反,我看到 things 提到 "works after 2.3.2",我就是。

PS:

任何人都可以解释链接 post 末尾描述的奇怪的 Ctrl-D 行为。我遇到了同样的情况,考虑到 Ctrl-D 应该退出这一事实,这似乎很奇怪...

好吧,网淘多了,终于崩溃挖了Play!框架 github 找到他们的测试 built.sbt,恰好使用了 new 选项。

显然,在迁移指南的深处已经注意到了这一点。 (我花了一些时间来回顾它。)

显然,我的错误在于假设 2.4.0 包含在 2.3.2+ 中,而没有检查隐藏得很好的(以我的拙见)文档。对于遇到类似情况而跌跌撞撞的任何其他人,请不要再观望:

PlayKeys.fileWatchService := play.sbtplugin.run.PlayWatchService.sbt(pollInterval.value)

2.4.0 开始,这是播放轮询的新语法。如果这导致另一个错误,请检查您正在使用的版本的迁移报告,看看他们是否再次更改了它。


只是想知道,我是否疯狂地期待某种 This is Deprecated 消息被吐出来,而不是只是盲目地谴责我所做的一切?这似乎是对未来有益的东西。

error: value playWatchService is not a member of object play.sbt.Play.autoImport.PlayKeys

error: object sbtplugin is not a member of package play

在 Playframework 2.4.X 中,SBT 设置键 playWatchService 已重命名为 fileWatchService

相应的class也发生了变化。要将 FileWatchService 设置为每两秒轮询一次,请像这样使用它:

scala PlayKeys.fileWatchService := play.runsupport.FileWatchService.sbt(2000)

摘自:https://www.playframework.com/documentation/2.4.x/Migration24#playWatchService-renamed