【问题标题】:Setting up Play Framework 2.3.x with Java 7 support设置支持 Java 7 的 Play Framework 2.3.x
【发布时间】:2015-12-26 20:49:13
【问题描述】:

我想设置一个在 Java 7 上运行的 Play Framework 应用程序。最新版本的 Play Framework 不支持 Java 7。所以通过查看 change log 我发现 2.3.10 是我想要的。

奇怪的是,每个 2.3.x+ 版本的激活器链接都指向同一个地方。此外,下载并运行它们将设置 Play Framework 2.4.3,而无需询问任何类型的问题。

下面是我的终端输出:

shyam@shyam-work:~/Applications/activator-1.3.6-minimal$ cd
shyam@shyam-work:~$ cd Applications
shyam@shyam-work:~/Applications$ cd activator-1.3.6-minimal/
shyam@shyam-work:~/Applications/activator-1.3.6-minimal$ ./activator new

Fetching the latest list of templates...

Browse the list of templates: http://typesafe.com/activator/templates
Choose from these featured templates or enter a template name:
  1) minimal-akka-java-seed
  2) minimal-akka-scala-seed
  3) minimal-java
  4) minimal-scala
  5) play-java
  6) play-scala
(hit tab to see a list of all templates)
> 5
Enter a name for your application (just press enter for 'play-java')
> play-java
OK, application "play-java" is being created using the "play-java" template.

To run "play-java" from the command line, "cd play-java" then:
/home/shyam/Applications/activator-1.3.6-minimal/play-java/activator run

To run the test for "play-java" from the command line, "cd play-java" then:
/home/shyam/Applications/activator-1.3.6-minimal/play-java/activator test

To run the Activator UI for "play-java" from the command line, "cd play-java" then:
/home/shyam/Applications/activator-1.3.6-minimal/plpay-java/activator ui

shyam@shyam-work:~/Applications/activator-1.3.6-minimal$ cd play-java/
shyam@shyam-work:~/Applications/activator-1.3.6-minimal/play-java$ cd project/
shyam@shyam-work:~/Applications/activator-1.3.6-minimal/play-java/project$ ls
build.properties  plugins.sbt
shyam@shyam-work:~/Applications/activator-1.3.6-minimal/play-java/project$ nano plugins.sbt

  GNU nano 2.2.6          File: plugins.sbt                            

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3")

// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")

// Play enhancer - this automatically generates getters/setters for pu$
// and rewrites accessors of these fields to use the getters/setters. $
// plugin if you prefer not to have this feature, or disable on a per $
// basis using disablePlugins(PlayEnhancer) in your build.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

// Play Ebean support, to enable, uncomment this line, and enable in y$
// enablePlugins(SbtEbean). Note, uncommenting this line will automati$
// Play enhancer, regardless of whether the line above is commented ou$
// addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")

如您所见,plugins.sbt 文件显示 2.4.3 并且在 Java 7 上构建失败。

现在,我已经通过下载 2.3.10 和 2.3.9 版本的链接进行了尝试。在这两种情况下,产生了相同的结果。

因此,我尝试了this,但这完全导致了不同的构建失败错误。

/home/shyam/Applications/activator-1.3.6-minimal/play-java/build.sbt:17: error: not found: value routesGenerator
routesGenerator := InjectedRoutesGenerator
^
[error] Type error in expression

我尝试用另一个 SO 帖子修复此问题(不幸的是,我前一段时间尝试过,此时我没有耐心再次经历这一切),这也给出了一个全新的错误。

所以我的问题是:实际设置一个简单的 Play Framework 应用程序以在 Java 7 上运行有多难?

【问题讨论】:

  • 您可以尝试 2.2.x 版本之一。他们不使用这个激活器。
  • 是的。那可能行得通。我真的很想知道为什么这不起作用。

标签: java playframework


【解决方案1】:

据我了解,Activator 无法确定播放的版本。它使用plugins.sbt 等文件中的信息来确定该特定应用程序将使用哪个版本的播放。这就是为什么不同版本的链接指向同一个激活器的原因。

plugins.sbt 随附您正在下载的模板(种子应用程序),因此您需要一个 2.3.x 模板(例如,尝试从 activator templates page 手动下载一个),或者您需要“反向迁移" 您下载的 2.4 应用程序(可能是一个相当耗时的练习,因为版本之间有一些重要的变化)。

【讨论】:

    猜你喜欢
    • 2015-12-09
    • 1970-01-01
    • 2014-09-01
    • 2020-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    相关资源
    最近更新 更多