玩! 2.2子项目拆分路由

时间:2014-01-31 18:23:03

标签: scala playframework

我正在分割Scala / Play! 2.2项目进入模块。路由拆分无法编译,但实际的源代码似乎确实编译。这是我认为与问题相关的代码:

/build.sbt

import play.Project._

name := "edshare_play"

Common.settings

playScalaSettings

libraryDependencies ++= Common.libraryDependencies

routesImport += "_root_.utils.binders._"

resolvers ++= Common.resolvers

scalacOptions ++= Common.scalacOptions

Keys.fork in Test := false

lazy val root = project.in(file("."))
                       .aggregate(core, edmoderator)

lazy val edmoderator = project.in(file("modules/edmoderator"))
                              .dependsOn(core)

lazy val core = project.in(file("modules/core"))

/ CONF /路由

# Moderation API
->  /api/edmoderation               edmoderator.Routes

# Core API
->  /api                            core.Routes

/modules/edmoderator/conf/edmoderator.routes

GET     /:entity               controllers.edmoderator.Moderation.getUnmoderated(entity)
PUT     /:entity/:id           controllers.edmoderator.Moderation.moderateDocument(entity, id)

/modules/core/conf/core.Routes

GET     /entity/:entity                     controllers.Entity.list(entity)

编译器输出:

[error] /Users/user/dev/project/play/conf/routes:6: not found: value edmoderator
[error] ->  /api/edmoderation               edmoderator.Routes
[error] /Users/user/dev/project/play/conf/routes:9: not found: value core
[error] ->  /api                            core.Routes
[error] /Users/user/dev/project/play/conf/routes: not found: value edmoderator
[error] /Users/user/dev/project/play/conf/routes:9: not found: value edmoderator
[error] ->  /api                            core.Routes
[error] /Users/user/dev/project/play/conf/routes:6: not found: value handler
[error] ->  /api/edmoderation               edmoderator.Routes
[error] /Users/user/dev/project/play/conf/routes:9: not found: value handler
[error] ->  /api                            core.Routes
[error] 6 errors found

我认为我可能在某个地方犯了一个简单的错误,但是我无法找到它。提前感谢任何指示。

1 个答案:

答案 0 :(得分:2)

我相信您在配置中缺少以下内容:

lazy val root = project.in(file("."))
                        .aggregate(core, edmoderator)
                        .dependsOn(core, edmoderator)

而不只是:

lazy val root = project.in(file("."))
                       .aggregate(core, edmoderator)

您可以在此处查看示例:

https://github.com/cnicodeme/play2.2-subproject