无法创建多项目构建

时间:2016-03-14 12:00:12

标签: scala playframework sbt

我正在尝试创建一个带有后端和前端的Play应用程序(使用Scala.js)。我将代码分为clientserver文件夹。

为了创建Multi Project Build,我查看了这个http://www.scala-sbt.org/release/docs/Multi-Project.html并将build.sbt设为这样:

name := """ScalaWeb"""

version := "1.0-SNAPSHOT"

lazy val commonSettings = Seq(
  scalaVersion := "2.11.7",

  libraryDependencies ++= Seq(
    jdbc,
    cache,
    ws,
    specs2 % Test
  ),

  libraryDependencies ++= Seq(
    "org.sorm-framework" % "sorm" % "0.3.19",
    "org.scala-lang" % "scala-compiler" % scalaVersion.value force(),
    "com.h2database" % "h2" % "1.3.148"
  ),

  libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0",

  /*libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0",
  libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.12"
  libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.3"*/

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

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

  scalacOptions += "-Ylog-classpath",

  // use this if you just want jawn's parser, and will implement your own facade
  libraryDependencies += "org.spire-math" %% "jawn-parser" % "0.8.3",

  // use this if you want jawn's parser and also jawn's ast
  libraryDependencies += "org.spire-math" %% "jawn-ast" % "0.8.3",

  //for reading Json libraries
  libraryDependencies +=  "org.scalaj" %% "scalaj-http" % "2.2.1"
)

lazy val server = (project in file("server")).settings(
  commonSettings: _*
).enablePlugins(PlayScala)

lazy val client = (project in file("client")).settings(
  commonSettings: _*
).enablePlugins(PlayScala)

fork in run := true

所以基本上我将所有依赖项放入commonSettings并将其导入到clientserver项目中。

但是,我收到此错误:

[error] (scalaweb/compile:backgroundRun) No main class detected.

为什么会这样? 我是否错误地设置了build.sbt

1 个答案:

答案 0 :(得分:1)

那是因为您的根项目(scalaweb)没有主类。

你可以:

  1. 通过执行以下操作运行服务器的运行命令:server / run
  2. 在根项目下聚合客户端和服务器 (http://www.scala-sbt.org/0.13/docs/Multi-Project.html#Aggregation
  3. 这可能会做你想要的。