2

Play フレームワークではかなり新しいですが、メイン プロジェクトのサブプロジェクトをセットアップしようとしましたが、ルートをメイン プロジェクトからサブプロジェクトにリダイレクトしようとすると、サブプロジェクト変数を認識できませんでした。ここのドキュメントに基づいてフォローしましたPlaySubProject

私の主なプロジェクト構造は次のとおりです。

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。この問題を解決するには?

4

2 に答える 2

1

私は同じ問題を抱えていました(プロジェクト構造はすべての例とドキュメントとルートファイルと同じでしたが、ルートファイルは適切な場所にありました)-サブプロジェクトルートファイルはメインターゲット/scala-2.11/routesに配置されておらず、できませんでした見つからない

unmanagedResourceDirectories in Compile += baseDirectory.value / "<path_to_project>/confbuild.sbt の最後に追加して解決しました:

....
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

サブプロジェクトのconfディレクトリの下にファイルを追加してメインプロジェクトのクラスパスに含めるには、sbtと言うでしょう

于 2016-07-22T11:37:18.190 に答える
0

特定の問題についてはわかりませんが、 https://github.com/josh-padnick/play-multiproject-templateで、完全に機能し、十分に文書化されたマルチプロジェクトの例をセットアップしました。これは Play 2.2.3 (2.3.x ではありません) に基づいていますが、必要なものにかなり近いはずです。

于 2014-10-04T05:09:28.310 に答える