Scala Play2.4 / Sbt多项目构建无法正常工作

时间:2016-05-01 12:53:53

标签: scala build sbt playframework-2.4

我试图将我的sbt scala Play项目分成几个可构建的模块。我阅读了the official sbt multi-project guidePlay 2.4.x multi-project guide和以下示例:playing-microservicesthe example from the Scala CookbookAnother good example。他们都巧妙地分歧,到目前为止我没有运气。

我一直得到以下内容:

$ sbt (or ./activator)

> project myPlay
> compile
... OK 
> start
...
(Starting server. Type Ctrl+D to exit logs, the server will remain in background)

Error: Could not find or load main class play.core.server.ProdServerStart

我如何解决这个问题?

这就是我的所作所为:

我的第一步是创建两个顶级目录:my-common-libmy-play-proj。我已将/app /conf /public /test移至/my-play-project,并在/src/main/scala/fooPackage/..中创建了my-common-lib目录,s.t。:

/my-common-lib
- /src
/my-play-project
- /app
- /conf
  - /application.conf
  - /routes
  - /evolutions
  ...
- /test
- /public
/build.sbt
/project
- /build.properties
- /plugins.sbt

然后我按如下方式更改了build.sbt

import sbt.Keys._

lazy val root = (project in file (".")) settings (
    name := "root-overlord",
    version := "1.0.0"
  ) aggregate (common, myPlay)

lazy val common = (project in file ("my-common-lib")) settings (commonSettings: _*) settings (
    name := "some-common-lib",
    version := "1.0.0"
  )

lazy val myPlay = (project in file ("my-play-project")).
  enablePlugins(PlayScala).
  settings(commonSettings: _*).
  settings (
    name := """my-play""",
    version := "1.8.2",
    // Play provides two styles of routers, one expects its actions to be injected, the
    // other, legacy style, accesses its actions statically.
    routesGenerator := InjectedRoutesGenerator,
    javaOptions in run += "-javaagent:" + System.getProperty("user.home") + "/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.8.jar -Xmx2G",
    fork in run := true,
    connectInput in run := true,
    javaOptions in Test += "-Dconfig.resource=test.application.conf",
    parallelExecution in Test := false,
    packageName in Universal := "myPlayProj"
  ).
  dependsOn(common % "compile->compile;test->test")


lazy val commonSettings = Seq (
  organization := "the-great-empire",
  scalaVersion := "2.11.8",
  libraryDependencies := Seq(
       ...
  ),
  resolvers := Seq(
    ...
  ),
  javaOptions in Test += "-Dconfig.resource=test.application.conf",
  parallelExecution in Test := false
)

有什么想法吗?

非常感谢。

0 个答案:

没有答案