0
我想創建一個多項目helloWorld在Play 2.5中使用Java的微服務,我找不到任何適合的模板或教程來啓動。 我的問題是我想創建一個項目,可以在同一時間運行,並可以通過REST接口訪問。與Java的Play Framework的微服務模板項目
有什麼想法?
我想創建一個多項目helloWorld在Play 2.5中使用Java的微服務,我找不到任何適合的模板或教程來啓動。 我的問題是我想創建一個項目,可以在同一時間運行,並可以通過REST接口訪問。與Java的Play Framework的微服務模板項目
有什麼想法?
嘿,這是所有關於SBT多項目配置例如:
name := "microservices"
scalaVersion in ThisBuild := "2.11.8"
autoScalaLibrary := false
def module(id: String, names: String) = Project(id, file(names))
.settings(javacOptions in compile ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8", "-Xlint:unchecked", "-Xlint:deprecation"))
.settings(jacksonParameterNamesJavacSettings: _*)
lazy val jacksonParameterNamesJavacSettings = Seq(
javacOptions in compile += "-parameters"
)
lazy val common = module("common", "modules/common")
lazy val aws = module("aws", "modules/aws")
.aggregate(common)
.dependsOn(common)
lazy val keywords = module("keywords", "keywords")
.enablePlugins(PlayJava, JavaAppPackaging, DockerPlugin)
.dependsOn(common, aws)
.aggregate(common, aws)
lazy val users = module("users", "users")
.enablePlugins(PlayJava, JavaAppPackaging, DockerPlugin)
.dependsOn(common, aws)
.aggregate(common, aws)
例如文件夾結構:
用戶/ build.sbt
name := """users"""
scalaVersion in ThisBuild := "2.11.8"
PlayKeys.devSettings := Seq("play.server.http.port" -> "9001")
// application version release
version := "2.8"
libraryDependencies ++= Seq(
cache,
javaWs,
"junit" % "junit" % "4.12",
"org.mockito" % "mockito-all" % "1.10.19",
"mysql" % "mysql-connector-java" % "6.0.4"
)
routesGenerator := InjectedRoutesGenerator
dockerExposedPorts in Docker := Seq(9001)
關鍵字/ build.sbt
name := """keywords"""
PlayKeys.devSettings := Seq("play.server.http.port" -> "9002")
scalaVersion in ThisBuild := "2.11.8"
// application version release
version := "1.0"
libraryDependencies ++= Seq(
cache,
javaWs,
"junit" % "junit" % "4.12",
"org.mockito" % "mockito-all" % "1.10.19",
"mysql" % "mysql-connector-java" % "6.0.4"
)
routesGenerator := InjectedRoutesGenerator
dockerExposedPorts in Docker := Seq(9000)
然後,你需要運行SBT並導航到期望的項目並運行它,所以你運行它們作爲兩個獨立的過程:
我會爲您提供示例模板在github明天運行。
https://www.lightbend.com/activator/template/playing-microservices 它在2.4,但我想你可以有一個想法是怎麼回事。 –