使用Play!Framework 2.2子项目

时间:2013-10-16 12:14:12

标签: playframework-2.2

我正在尝试在子项目中拆分我的Play!Framework 2.2项目,我很难搞清楚它。

这是我的文件夹结构:

MyProject/
 | - app/
 | --- controllers/ # containing some main controllers
 | --- views/ # resulting views
 | - build.sbt # see after
 | - conf/
 | --- application.conf
 | --- routes
 | --- modules/ # My modules folder, aka sub projects
 | -------- common/
 | ------------ app/
 | --------------- models/ # The models
 | --------------- utils/
 | -------- api/
 | -------- web/
 | ------------ app/ # some controllers/views
 | ------------ conf/ # routes mainly
 | ------------ app/ # some controllers/views
 | ------------ conf/ # routes mainly

(我简化了)。

routes文件:

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET     /                             controllers.StaticPages.index()

# Web
->  /html/v1 web.Routes

# API
->  /api/v1  api.Routes

web.routes:

# HTML Engine renderer
# ~~~~~~~~~~~~~~~~~~~~

GET   /users                controllers.Users.list()

api.routes:

# API
# ~~~~~~~~~~~~~~~~~~~~

GET   /users                controllers.Users.list()

最后,我的build.sbt

import play.Project._

name := "My project"

version := "1.0-alpha"

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  "mysql" % "mysql-connector-java" % "5.1.25",
  "com.typesafe" %% "play-plugins-mailer" % "2.2.0"
)

play.Project.playJavaSettings

lazy val root = project.in(file("."))
    .dependsOn(common, web, api)
    .aggregate(common, web, api)

lazy val web = project.in(file("modules/web"))
    .dependsOn(common)

lazy val api = project.in(file("modules/api"))
    .dependsOn(common)

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

清洁/编译和运行时,我遇到了这个错误:

  

未找到:重视网络   在第20行的/ path / to / project / conf / routes中。    - > / html / v1 web.Routes

如果我删除了主->文件中的routes,请播放!无法找到共同的包工具。

所以我猜普通,web和api没有加载,但为什么?

更新

由于@ James-roper帮我找到了问题,我创建了一个Github存储库,显示了一个简单的Play!Framework 2.2项目和子项目。您可以在此处找到它:https://github.com/cnicodeme/play2.2-subproject

1 个答案:

答案 0 :(得分:11)

您的子项目需要使用不同的软件包名称,而这些名称是冲突的。