我有一個玩! 2.5.3項目有一個子項目(有自己的路線)。在主要航線文件子項目的路線如下定義:玩與子項目路線
-> /api api.Routes
GET /assets/*file controllers.Assets.at(path="/public", file)
和api.routes
文件是folllows:
GET /v1/permissions/roles controllers.api.PermissionsController.roles
所以來回獲取角色的網址是/api/v1/permissions/roles
。
當我運行根項目(這取決於兩個子項目)一切工作正常,但分別運行每個子項目時,找不到路由。我試圖在構建過程中將主路徑文件複製到構建子項目的conf
文件夾中,但它不起作用。
我發現的唯一的解決辦法是添加在application.conf
play.http.router = "api.Routes"
,但路線「失去」了/api
前綴(即:API路線/v1/permissions/roles
)
所以我的問題是:是有可能有一個子項目與路線,並且這些路線在運行根項目和分別運行每個子項目時是相同的?
如果有可能,是否在文檔中的任何位置?
編輯:
build.sbt
根項目
name := """abc"""
version := "0.1.0"
scalaVersion := "2.11.7"
resolvers += Resolver.jcenterRepo
javaOptions in Test += "-Dconfig.file=conf/test.conf"
javaOptions in Test += "-Dtest.timeout=600000"
lazy val abcCore = (project in file("modules/abc-core")).enablePlugins(PlayJava, PlayEbean)
lazy val abcCentral = (project in file("modules/abc-central")).enablePlugins(PlayJava, PlayEbean)
.dependsOn(abcCore)
.aggregate(abcCore)
lazy val abcSimulador = (project in file("modules/abc-simulador")).enablePlugins(PlayJava, PlayEbean)
.dependsOn(abcCore)
.aggregate(abcCore)
lazy val abcDevice = (project in file("modules/abc-device")).enablePlugins(PlayJava, PlayEbean)
.dependsOn(abcCore)
.aggregate(abcCore)
lazy val abcApi = (project in file("modules/abc-api")).enablePlugins(PlayJava, PlayEbean)
.dependsOn(abcCore, abcSimulador)
.aggregate(abcCore, abcSimulador)
lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)
.dependsOn(abcCore, abcDevice, abcCentral, abcSimulador, abcApi)
.aggregate(abcCore, abcDevice, abcCentral, abcSimulador, abcApi)
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs,
"uk.co.panaxiom" %% "play-jongo" % "2.0.0-jongo1.3",
"be.objectify" %% "deadbolt-java" % "2.5.0",
"mysql" % "mysql-connector-java" % "5.1.36",
"org.hibernate" % "hibernate-validator" % "5.2.4.Final",
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.7.5",
"uk.co.modular-it" % "bean-utils" % "0.9.10",
"org.hamcrest" % "hamcrest-library" % "1.3",
"commons-beanutils" % "commons-beanutils" % "1.9.2",
"net.coobird" % "thumbnailator" % "0.4.8",
"io.moquette" % "moquette-broker" % "0.8.1" exclude("org.slf4j", "slf4j-log4j12"),
"org.mindrot" % "jbcrypt" % "0.3m",
"org.apache.commons" % "commons-math3" % "3.6.1",
"com.typesafe.play" %% "play-mailer" % "5.0.0",
"org.thymeleaf" % "thymeleaf" % "3.0.1.RELEASE",
"org.jetbrains.kotlin" % "kotlin-stdlib" % "1.0.3",
"org.eclipse.collections" % "eclipse-collections-api" % "7.1.0",
"org.eclipse.collections" % "eclipse-collections" % "7.1.0",
"org.eclipse.collections" % "eclipse-collections-forkjoin" % "7.1.0",
"net.jpountz.lz4" % "lz4" % "1.3.0",
"org.mapdb" % "elsa" % "3.0.0-M6",
"com.google.guava" % "guava" % "19.0",
"org.jfree" % "jfreesvg" % "3.1",
"net.sf.jasperreports" % "jasperreports" % "6.3.1",
"com.github.jhonnymertz" % "java-wkhtmltopdf-wrapper" % "1.0.1-RELEASE",
"org.awaitility" % "awaitility-scala" % "2.0.0",
"org.fusesource.mqtt-client" % "mqtt-client" % "1.14")
jacoco.settings
parallelExecution in jacoco.Config := false
jacoco.reportFormats in jacoco.Config := Seq(
de.johoop.jacoco4sbt.ScalaHTMLReport(encoding = "utf-8", withBranchCoverage = true),
de.johoop.jacoco4sbt.XMLReport(encoding = "utf-8"))
fork in run := false
fork in Test := false
mappings in Universal <++= (packageBin in Compile) map { jar =>
val scriptsDir = new java.io.File("modules/abc-api/app/templates/")
scriptsDir.listFiles.toSeq.map { f =>
f -> ("app/templates/" + f.getName)
}
}
mappings in Universal <++= (packageBin in Compile) map { jar =>
val scriptsDir = new java.io.File("modules/abc-api/public/images/")
scriptsDir.listFiles.toSeq.map { f =>
f -> ("public/images/" + f.getName)
}
}
爲什麼你想分別運行它們?你也可以分享你的build.sbt嗎? –
在生產中,每個子項目(有5個)在其自己的服務器上運行,並且它們通過REST API進行通信。 – ppires