我试图将我的sbt scala Play项目分成几个可构建的模块。我阅读了the official sbt multi-project guide,Play 2.4.x multi-project guide和以下示例:playing-microservices和the example from the Scala Cookbook,Another 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-lib
和my-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
)
有什么想法吗?
非常感谢。