播放框架从2.0.8迁移到2.1.0动态表单找不到符号

时间:2015-02-02 10:43:48

标签: java playframework playframework-2.0 migration playframework-2.1

我已经将游戏框架从2.0.8迁移到2.1.0,我已经遵循了这个guide

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

这是我的代码:

  

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

                        ^cannot find symbol

我还导入:import 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)
)}

编辑:

  

通过向上移动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",

)

2 个答案:

答案 0 :(得分:1)

来自Play 2.1 migration guide

  

play.mvc.Controller.form()重命名为play.data.Form.form()   与模块化相关,play.data包及其依赖关系   从play核心转移到javaCore工件。作为结果   其中,play.mvc.Controller#form已移至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

答案 1 :(得分:0)

替换为:

Form.form().bindFromRequest();

form()是一个静态方法,因此您需要一个静态导入或代码,如上所述。