我的主要项目结构如下图所示:
Main
app
conf
application.conf
routes
modules
sub
app
conf
sub.routes
build.sbt
logs
project
public
target
test
activator
activator-launch-1.2.10.jar
build.sbt
这是我的主要build.sbt文件:
name := """Main"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava).aggregate(sub).dependsOn(sub)
lazy val sub = (project in file("modules/sub")).enablePlugins(PlayJava)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
javaWs
)
我的子项目build.sbt如下:
name := """Subproject"""
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
javaWs
)
最后,这是我的主要路线文件。
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
# SUB's
-> /sub sub.Routes
问题出在这个路径文件中,它甚至无法识别sub.Routes
最后一行的子变量。如何解决这个问题?
答案 0 :(得分:1)
我有同样的问题(虽然项目结构与所有示例和文档中的相同,路线文件位于正确的位置) - 子项目路线文件尚未被放入主目标/ scala-2.11 / routes并且无法找到
我在build.sbt:
的末尾添加unmanagedResourceDirectories in Compile += baseDirectory.value / "<path_to_project>/conf
解决了这个问题
....
lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)
.settings(commonSettings: _*)
.aggregate(core, providers, zms, api)
.dependsOn(core, providers, zms, api)
lazy val core = (project in file("apps/core")).enablePlugins(PlayJava, PlayEbean)
.settings(commonSettings: _*)
.settings(
name := "core"
)
lazy val zms = (project in file("apps/zms")).enablePlugins(PlayJava, PlayEbean)
.settings(commonSettings: _*)
.settings(
name := "zms"
)
.dependsOn(core)
lazy val api = (project in file("apps/api")).enablePlugins(PlayJava, PlayEbean)
.settings(commonSettings: _*)
.settings(
name := "api"
)
.dependsOn(core)
//Here are the lines that solved the problem
unmanagedResourceDirectories in Compile += baseDirectory.value / "apps/core/conf"
unmanagedResourceDirectories in Compile += baseDirectory.value / "apps/zms/conf"
unmanagedResourceDirectories in Compile += baseDirectory.value / "apps/api/conf"
fork in Compile := true
它会说sbt在子项目conf目录下添加文件以包含在主项目类路径中
答案 1 :(得分:0)
我不确定您的具体问题,但我在https://github.com/josh-padnick/play-multiproject-template设置了一个完全有效且记录完备的多项目示例。这是基于Play 2.2.3(不是2.3.x),但它应该非常接近你需要的。