gpt4 book ai didi

scala - 玩!框架和 SBT - ebean 模块的问题

转载 作者:行者123 更新时间:2023-12-01 10:00:18 25 4
gpt4 key购买 nike

(免责声明:我是一个完整的 Play/SBT 新手。)我一直在尝试跨两个子模块创建一个新项目,使用 play 作为 Web 前端(“app”模块),为核心模块(“core”)使用普通 scala。但是,我在尝试运行 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.

我看过迁移指南,但似乎帮助不大。在我看来,使用 Play! 并不需要 ebean!,但 sbt 似乎不想在没有它的情况下运行。此外,即使我将 ebeans 添加为 sbt 插件,它仍然存在问题。

项目/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)

}

项目/plugins.sbt

logLevel := Level.Warn

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

addSbtPlugin("org.scala-js" %% "sbt-scalajs" % "0.6.5")

最佳答案

您只需要将 Ebean 添加为插件并将其启用为 Play offical documentation说:

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 extractedout of the Play sbt plugin into its own plugin.

To migrate an existing Play project that uses Ebean to use the newexternal Ebean plugin, remove javaEbean from your libraryDependenciesin 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 listinstead of a comma separated string (which is still supported but wasdeprecated):

  • 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 addeditself, including the Model class. Consequently, the Play Model classhas been deprecated, in favour of using com.avaje.ebean.Model.

关于scala - 玩!框架和 SBT - ebean 模块的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33074194/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com