Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play! Framework and SBT - Problems with ebeans module

(Disclaimer: I'm a complete Play/SBT newbie.) I've been trying to create a new project across two sub-modules using play for a web front-end (the "app" module) and plain scala for the core module ("core"). However, I've been running into problems where trying to run sbt:

[info] Loading project definition from /home/rm/PlayApp/project Play ebean module has been replaced with an external Play ebean plugin. See https://playframework.com/documentation/2.4.x/Migration24 for details.

I've looked at the migration guide, and it doesn't seem to help much. It doesn't seem to me that ebeans is required to use Play!, but sbt doesn't seem to want to run without it. Furthermore, even when I add ebeans as a sbt plugin, it still has problems.

project/Build.scala

import org.scalajs.sbtplugin.ScalaJSPlugin
import play.sbt.PlayScala
import sbt.{Build => SbtBuild, _}
import Keys._


object BuildSettings {
  val buildSettings = Defaults.coreDefaultSettings ++ Seq(
    scalaVersion := "2.11.7",
    version := "1.0.0",
    resolvers += Resolver.sonatypeRepo("releases"),
    resolvers += Resolver.url("scalajs-repo", new java.net.URL("http://mvnrepository.com/artifact/org.scala-js")),
    scalacOptions ++= Seq()
  )
}

object Dependencies {
  val playjson = "com.typesafe.play" %% "play-json" % "2.4.3"
}

object Build extends SbtBuild {

  import BuildSettings._
  import Dependencies._

  lazy val root = Project(id = "Application",
    base = file("."),
    settings = buildSettings ++ Seq(
      run <<= run in Compile in core
    )
  ).aggregate(core)


  lazy val core = Project("core",
    file("core"),
    settings = buildSettings
  )

  lazy val app = Project("app",
    file("app"),
    settings = buildSettings ++ Seq(
      libraryDependencies ++= Seq(
        playjson
      )
    )
  ).enablePlugins(PlayScala, ScalaJSPlugin)

}

project/plugins.sbt

logLevel := Level.Warn

addSbtPlugin("com.typesafe.play" %% "sbt-plugin" % "2.4.3")

addSbtPlugin("org.scala-js" %% "sbt-scalajs" % "0.6.5")
like image 714
memleek Avatar asked Feb 07 '26 03:02

memleek


1 Answers

You just need to add Ebean as a plugin and enable it as the Play offical documentation says:

Ebean dependency

Ebean has been pulled out into an external project, to allow it to have a lifecycle independent of Play’s own lifecycle. The Ebean bytecode enhancement functionality has also been extracted out of the Play sbt plugin into its own plugin.

To migrate an existing Play project that uses Ebean to use the new external Ebean plugin, remove javaEbean from your libraryDependencies in build.sbt, and add the following to project/plugins.sbt:

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

After that, enable Ebean plugin for your project:

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

And finally, configure Ebean mapped classes as a list instead of a comma separated string (which is still supported but was deprecated):

  • ebean.default = ["models.*"]

  • ebean.orders = ["models.Order","models.OrderItem"]

Additionally, Ebean has been upgraded to 4.5.x, which pulls in a few of the features that Play previously added itself, including the Model class. Consequently, the Play Model class has been deprecated, in favour of using com.avaje.ebean.Model.

like image 55
G. I. Joe Avatar answered Feb 12 '26 06:02

G. I. Joe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!