播放2.4.x包play.db.ebean不存在

时间:2015-11-08 09:46:53

标签: playframework

使用激活器创建新应用程序后,我尝试连接到数据库并配置连接到数据库所需的所有必要步骤(通过Play网站进行跟踪)。

我无法成功并始终遇到此错误。

这是我的build.sbt

name := """xxxxx"""

version := "1.0-SNAPSHOT"

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

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  javaJdbc,
  javaJpa,
  cache,
  javaWs,
  evolutions
)
libraryDependencies += specs2 % Test

resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"

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


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

[已更新]这是我的projects/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")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.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(SbtEbean). 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")

这是我的application.conf

# Configure Ebean
ebean.default = ["models.*"]

#JPA Configuration
jpa.default=defaultPersistenceUnit

# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
 db.default.driver=org.h2.Driver
 db.default.url="jdbc:h2:mem:play"
 db.default.username=sa
 db.default.password=""

播放2.4.x中是否弃用了play.db.ebean.Model?

我附上了错误的屏幕截图。

play.db.ebean does not exist

package com.avaje.ebean does not exist

2 个答案:

答案 0 :(得分:1)

2.4中的

As announced before默认情况下不再启用Ebean。幸运的是,它仍然受支持,您可以轻松启用它。

  1. project/plugins.sbt取消注释最后一行:

    addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")
    
  2. build.sbtPlayEbean插件添加到root

    lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)
    
  3. 另外正如您现在注意到的那样,您应该使用原生Ebean' com.avaje.ebean.Model代替play.db.ebean.Model

    最后,您现在应该为没有ID类型的模型声明一个Finder,因此它将是:

    public static final Finder<Long, Foo> find = new Finder<>(Foo.class);
    

    而不是

    public static final Finder<Long, Foo> find = new Finder<>(Long.class, Foo.class);
    

答案 1 :(得分:-1)

你需要运行:     发挥想法或激活者的想法     玩日食或激活日食

在添加依赖项之后,您需要为特定IDEA(Eclipse,intellij)重新生成代码。