13

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"))

クリーニング/コンパイルして実行すると、次のエラーに直面します:

見つかりません: 値 web /path/to/project/conf/routes の 20 行目。 -> /html/v1 web.Routes

->メインroutesファイルの を削除すると、Play! 共通のパッケージ utils が見つかりません。

よくあることだと思いますが、web と api が読み込まれていませんが、なぜですか?

アップデート

@James-roper が問題の発見を手伝ってくれたので、サブプロジェクトを含む単純な Play!Framework 2.2 プロジェクトを示す Github リポジトリを作成しました。ここで見つけることができます: https://github.com/cnicodeme/play2.2-subproject

4

1 に答える 1

11

サブプロジェクトは、競合している時点で異なるパッケージ名を使用する必要があります。

于 2013-10-18T01:00:08.190 に答える