play framework 从 2.0.8 迁移到 2.1.0 动态表单找不到符号

play framework migration from 2.0.8 to 2.1.0 Dynamic form cannot find symbol

我已经将 play framework 从 2.0.8 迁移到 2.1.0,并且我遵循了这个 guide

但我在使用动态表单时遇到错误找不到符号

这是我的代码:

final DynamicForm form = form().bindFromRequest();

                        ^cannot find symbol

我也导入了:导入play.data.Form;

有人知道我在迁移过程中遗漏了什么吗?

编辑:这是我的 build.scala

import sbt._
import Keys._
import play.Project._
import com.github.play2war.plugin._

object ApplicationBuild extends Build {val appName         = "Lndlabproject"
val appVersion      = "1.0-SNAPSHOT"
val appDependencies = Seq(
  "mysql" % "mysql-connector-java" % "5.1.18",
  "org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final",
  "org.apache.httpcomponents" % "httpclient"  % "4.0.3",
  "japid42" % "japid42_2.9.1" % "0.5.3",
  "org.apache.poi" % "poi" % "3.8",
  "org.apache.poi" % "poi-ooxml" % "3.9",
  "com.feth" %% "play-easymail" % "0.1-SNAPSHOT",
  "org.apache.directory.studio" % "org.apache.commons.io" % "2.4",
  "org.apache.ant" % "ant-jsch" % "1.7.1",
  javaCore,
  javaJdbc,
  javaEbean
)

val main = play.Project(appName, appVersion, appDependencies).settings(

    Play2WarPlugin.play2WarSettings: _*)
    .settings(Play2WarKeys.servletVersion := "2.5")
    .settings(

  // Add your own project settings here      
  ebeanEnabled := false, 
  resolvers += Resolver.url("My GitHub Play Repository", url("http://branaway.github.com/releases/"))(Resolver.ivyStylePatterns),

  resolvers += Resolver.url("play-easymail (release)", url("http://joscha.github.com/play-easymail/repo/releases/"))(Resolver.ivyStylePatterns),resolvers += Resolver.url("play-easymail (snapshot)", url("http://joscha.github.com/play-easymail/repo/snapshots/"))(Resolver.ivyStylePatterns)
)}

编辑:

resolved issue by moving javaCore, javaJdbc, javaEbean dependencies upwards.

喜欢

 val appDependencies = Seq(
  javaCore,
  javaJdbc,
  javaEbean,
  "mysql" % "mysql-connector-java" % "5.1.18",
  "org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final",
  "org.apache.httpcomponents" % "httpclient"  % "4.0.3",
  "japid42" % "japid42_2.9.1" % "0.5.3",
  "org.apache.poi" % "poi" % "3.8",
  "org.apache.poi" % "poi-ooxml" % "3.9",
  "com.feth" %% "play-easymail" % "0.1-SNAPSHOT",
  "org.apache.directory.studio" % "org.apache.commons.io" % "2.4",
  "org.apache.ant" % "ant-jsch" % "1.7.1",

)

替换为:

Form.form().bindFromRequest();

form() 是一个静态方法,因此你需要一个静态导入或上面的代码。

来自 Play 2.1 migration guide.

play.mvc.Controller.form() renamed to play.data.Form.form() Also related to modularization, the play.data package and its dependencies were moved out from play core to javaCore artifact. As a consequence of this, play.mvc.Controller#form was moved to play.data.Form#form

DynamicForm form = Form.form().bindFromRequest();也是

在你的build.scala中(即你在下面的评论中显示)javaCore依赖项在最后

 val appDependencies = Seq( 

"mysql" % "mysql-connector-java" % "5.1.18", 

"org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final", 

"org.apache.httpcomponents" % "httpclient" % "4.0.3",

 "japid42" % "japid42_2.9.1" % "0.5.3", 

"org.apache.poi" % "poi" % "3.8", "org.apache.poi" % "poi-ooxml" % "3.9", 

"com.feth" %% "play-easymail" % "0.1-SNAPSHOT", 

"org.apache.directory.studio" % "org.apache.commons.io" % "2.4", 

"org.apache.ant" % "ant-jsch" % "1.7.1", 

javaCore, 

javaJdbc, 

javaEbean

   )

可能无法加载 javaCore 依赖项,所以将 javaCore,javaJdbc,javaEbean 移到顶部

val appDependencies = Seq( 

javaCore, 

javaJdbc, 

javaEbean,

"mysql" % "mysql-connector-java" % "5.1.18", 

"org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final", 

"org.apache.httpcomponents" % "httpclient" % "4.0.3",

 "japid42" % "japid42_2.9.1" % "0.5.3", 

"org.apache.poi" % "poi" % "3.8", "org.apache.poi" % "poi-ooxml" % "3.9", 

"com.feth" %% "play-easymail" % "0.1-SNAPSHOT", 

"org.apache.directory.studio" % "org.apache.commons.io" % "2.4", 

"org.apache.ant" % "ant-jsch" % "1.7.1"

   )

然后

play clean
play ~run