如何让 play.db.ebean.Model 处理我的新 PlayFramework 项目?

How can I get play.db.ebean.Model working on my new PlayFramework project?

我已经开始了一个游戏框架项目,使用控制台。一切看起来都很好。

我的 project/plugins.sbt 文件是

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

// 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 public fields
// and rewrites accessors of these fields to use the getters/setters. Remove this
// plugin if you prefer not to have this feature, or disable on a per project
// 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 your build.sbt using
// enablePlugins(PlayEbean). Note, uncommenting this line will automatically bring in
// Play enhancer, regardless of whether the line above is commented out or not.
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

为了让 ebean 正常工作,我取消了最后一行之前的注释。

我的 build.sbt 文件是

name := """whatever"""

version := "1.0-SNAPSHOT"

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

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


fork in run := true

在哪里,在 lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)

在我的 conf/application.conf 上,我已经添加了数据库连接字符串并定义了 ebean 的默认位置。

db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/whatever?characterEncoding=UTF-8"
db.default.user=whatever 
db.default.password=whateverUser

ebean.default="models.*"

我添加了 'PlayEbean' 部分。

在激活器控制台上,我执行清理、编译、eclipse。从 eclipse 中删除项目并重新导入它。

当我尝试开始使用这个 'high-productivity' 框架时,我卡在了我尝试构建的第一个模型上。

我哪里错了?

提前致谢!

随着 play 2.4 的发布,Ebean 支持已被提取到它自己的项目中。因此 play.db.ebean.Model 不再存在。请改用 com.avaje.ebean.Model