播放2.4 com.avaje.ebean.Model

时间:2015-09-21 15:00:18

标签: playframework ebean

这是我的第一篇文章,所以请保持温柔。我正在学习一些使用游戏的教程。我在2.4版本,但教程使用的是早期版本。我按照游戏网站上的指南来整合ebeansin 2.4。

My build.sbt

    name := """please-work"""

version := "1.0-SNAPSHOT"

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

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs,
  "org.avaje.ebeanorm" % "avaje-ebeanorm" % "6.8.1"
)

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

我的application.conf

db.default.driver = org.h2.Driver

 db.default.url="jdbc:h2:mem:play"
# db.default.username=sa
# db.default.password=""
 ebean.default = ["models.*"]

我的plugin.sbt

// 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")

这是使用库

的代码
package model;

import com.avaje.ebean.Model;
import javax.persistence.Entity;
import javax.persistence.Id;

/**
 * Created by craig.ledgerwood on 18/09/2015.
 */
@Entity
public class Person extends Model {
    @Id
    public String id;
    public String name;
}

最令人恼火的是,即使我没有改变任何事情,我的错误也在不断变化。最初是com.avaje.ebean.Model不可用。但现在我得到了

NoClassDefFoundError: com/avaje/ebeaninternal/server/ddl/DdlGenerator

请有人指出我正确的方向。我希望将来继续使用postgres数据库,但我希望在继续前进之前先了解基础知识,这些小绊脚石会让人感到沮丧,因为我确信它非常简单。

此致

克雷格

2 个答案:

答案 0 :(得分:1)

build.sbt

中删除以下依赖项
"org.avaje.ebeanorm" % "avaje-ebeanorm" % "6.8.1"

在你的 plugins.sbt 中,更新sbt-play-ebean

addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "2.0.0")

我在Play 2.4.6中解决了同样的问题,请参阅

答案 1 :(得分:0)

Ebean 6.8.1与当前的play-ebean工件之间存在不兼容性。

请参阅https://github.com/playframework/play-ebean/issues/53

......和:https://github.com/playframework/play-ebean/pull/56

相关问题